China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-07-31 20:45
中国DOS联盟论坛 » DOS开发编程 & 发展交流 (开发室) » Quick BASIC Program to Automatically Detect Whether a Chinese Character Support System Is Loaded View 2,946 Replies 12
Original Poster Posted 2004-02-27 00:00 ·  中国 广东 佛山 三水区 电信
元老会员
★★★★
Credits 5,170
Posts 1,637
Joined 2002-10-16 00:00
23-year member
UID 8
Gender Male
From 广东佛山
Status Offline
This was introduced in some collected volume. It originally explained how to detect it with C; later I implemented it in QB. Now that I've found the program, I'll post it here. As long as you use one variable to save the detection result and prepare two sets of displays, it can automatically adapt to whether there is a Chinese character support system.

REM Automatically detect the Chinese character support system in a BASIC program
DEF SEG = &H40
mode = PEEK(&H49)
OUT &H3CE, &H6
result = INP(&H3CF) AND &HF
PRINT "mode="; mode, "result="; result
IF mode = 3 AND result = 5 THEN
PRINT "You are now in a direct-screen-writing Chinese character support system"
PRINT "What you see now is Chinese"
ELSE
IF mode = 3 AND result = 14 THEN
PRINT "Is not any CCDOS in the memory ,It's it ?"
PRINT "So , You only see the English"
ELSE
IF mode = 18 AND result = 1 THEN
PRINT "You are now in a non-direct-screen-writing Chinese character support system"
ELSE
PRINT "I Can't know which display mode ."
END IF
END IF
END IF
我的网志
http://hzmys.blog.163.com/
我的网盘
firststep.qjwm.com
fsmys.ys168.com
ssmys.ys168.com
www.brsbox.com/fsmys
www.brsbox.com/ssmys
www.brsbox.com/ccdos
Floor 2 Posted 2004-02-28 00:00 ·  美国
系统支持
★★★★★★
“新DOS时代”站长
Credits 27,736
Posts 10,521
Joined 2002-10-09 12:00
23-year member
UID 9
Status Offline
Change this line in the program:

IF mode = 3 AND result = 5 THEN

to:

IF mode = 3 AND (result = 1 or result = 5) THEN

otherwise it won't be able to correctly determine whether the Chinese character support system is loaded under Chinese character support systems such as AW97 and XZL in the DOS window of Win9x/ME, or under pure DOS.

Wengier - 新DOS时代

欢迎大家来到我的“新DOS时代”网站,里面有各类DOS软件和资料,地址:
http://wendos.mycool.net/

E-Mail & MSN: wengierwu AT hotmail.com (最近比较忙,有事请联系DOSroot和雨露,谢谢!)

Floor 3 Posted 2004-03-02 00:00 ·  中国 辽宁 沈阳 联通
铂金会员
★★★★
痴迷DOS者
Credits 5,798
Posts 1,924
Joined 2003-06-20 00:00
23-year member
UID 5583
Gender Male
From 金獅電腦軟體工作室
Status Offline
I also have a piece of Quick BASIC code for determining whether the Chinese system has been started. I'll upload it another day to share with everyone.
熟能生巧,巧能生精,一艺不精,终生无成,精亦求精,始有所成,臻于完美,永无止境!
金狮電腦軟體工作室愿竭诚为您服务!
QQ群:8393170(定期清理不发言者)
个人网站:http://www.520269.cn
电子邮件:doujiehui@vip.qq.com
微信公众号: doujiehui
Floor 4 Posted 2004-03-21 00:00 ·  中国 辽宁 朝阳 联通
铂金会员
★★★★
痴迷DOS者
Credits 5,798
Posts 1,924
Joined 2003-06-20 00:00
23-year member
UID 5583
Gender Male
From 金獅電腦軟體工作室
Status Offline
CALL TestCcdos
SYSTEM

SUB TestCcdos
DIM a%(50)
DEF SEG = VARSEG(a%(0))
RESTORE
FOR I% = 0 TO 37
READ D%
IF I% = 4 THEN
D% = VARPTR(a%(49)) MOD 256
ELSEIF I% = 5 THEN
D% = VARPTR(a%(49)) / 256
END IF
POKE VARPTR(a%(0)) + I%, D%
NEXT I%

CALL ABSOLUTE(VARPTR(a%(0)))
DEF SEG
IF a%(49) = 0 THEN
PRINT
PRINT "This is a test program!"
PRINT "If you run it under Chinese System, Program will show GB Chinese char message."
PRINT
SYSTEM
ELSE
PRINT "This is a Chinese test program!"
PRINT "Copyright: Golden Lion Computer Software Studio, Dou Jiehui"
PRINT "Email: kinglionsoft@idvweb.com"

END IF
END SUB

DATA &H50,&H53,&H56,&HBE,&H00,&H00,&H2E,&HC7,&H04,&H00,&H00,&HB8,&H00,&HDB,&HCD,&H2F
DATA &H3C,&HFF,&H74,&H09,&HB8,&H10,&HDB,&HCD,&H10,&H3C,&HFF,&H75,&H05,&H2E,&HC7,&H04
DATA &H01,&H00,&H5E,&H5B,&H58,&HCB




熟能生巧,巧能生精,一艺不精,终生无成,精亦求精,始有所成,臻于完美,永无止境!
金狮電腦軟體工作室愿竭诚为您服务!
QQ群:8393170(定期清理不发言者)
个人网站:http://www.520269.cn
电子邮件:doujiehui@vip.qq.com
微信公众号: doujiehui
Floor 5 Posted 2009-07-05 10:57 ·  中国 广东 揭阳 电信
高级用户
★★
Credits 774
Posts 293
Joined 2003-04-16 00:00
23-year member
UID 1579
Gender Male
From 湖北仙桃
Status Offline
Bumping this old thread.
A question for everyone: after detecting whether the Chinese character support system is loaded like this, is it possible to add a new DOS environment variable?
Microsoft's method is to call a batch file again to set the environment variable: http://support.microsoft.com/kb/43691/zh-cn
vbdos's Environ can only modify or delete DOS environment variables that already exist, but it cannot add new environment variables.
That's very inconvenient. Is there any way to directly add an environment variable in QB?

[ Last edited by xugaohui on 2009-7-5 at 11:03 ]
下载
09年7月7日 更新
感谢网友 囧HQY 提供空间
Floor 6 Posted 2009-07-05 12:46 ·  中国 江苏 苏州 电信
银牌会员
★★★
Credits 2,227
Posts 790
Joined 2005-01-27 00:00
21-year member
UID 35703
Gender Male
Status Offline
No need for environment variables, just 7 lines of assembly code will do!
mov dx,3C4h
mov al,02
out dx,al
mov dx,3C5h
in al,dx
cmp al,03
On the next line, use JZ for English DOS or JNZ for Chinese DOS.
That's exactly how it's done in my VTmagik.com.
;jz EnDisp, jnz CcDisp
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
xugaohui +1 2009-07-05 13:27
my major is english----my love is dos----my teacher is the buddha----my friends--how about U
Floor 7 Posted 2009-07-05 13:10 ·  中国 广东 揭阳 电信
高级用户
★★
Credits 774
Posts 293
Joined 2003-04-16 00:00
23-year member
UID 1579
Gender Male
From 湖北仙桃
Status Offline
I don't understand assembly or C. What I had in mind was using a program to detect whether it's a Chinese environment, then setting the environment variable cn=1, so that any batch file under DOS could determine whether the current environment is Chinese. That would make it very convenient to create batch programs with Chinese and English displays. In Qb too, Chinese and English prompts could be entered. I checked Pascal as well and there is no command for adding environment variables.
Microsoft's website always gives this kind of explanation: http://support.microsoft.com/kb/69846/zh-cn
I'll try looking at PowerBASIC's help to see whether PEEK$ and POKE$ can solve the problem, though I guess that method isn't very good.

Tests show that PEEK$ and POKE$ don't work, because there are multiple Program Segment Prefixes PSP in memory, so a lot of environment variables can be found, but there's no way to know which one is the correct one.

[ Last edited by xugaohui on 2009-7-5 at 15:37 ]
下载
09年7月7日 更新
感谢网友 囧HQY 提供空间
Floor 8 Posted 2009-07-06 00:19 ·  中国 江苏 苏州 电信
银牌会员
★★★
Credits 2,227
Posts 790
Joined 2005-01-27 00:00
21-year member
UID 35703
Gender Male
Status Offline
The assembly in post #6 translated into BASIC is as follows:
REM Automatically detect the Chinese character support system in a BASIC program
OUT &H3C4, 02
result = INP(&H3C5) AND &HF
IF result = 3 THEN
PRINT "MS/PC DOS"
ELSE
PRINT "CCDOS"
END IF
END
my major is english----my love is dos----my teacher is the buddha----my friends--how about U
Floor 9 Posted 2009-07-06 04:45 ·  中国 广东 揭阳 电信
高级用户
★★
Credits 774
Posts 293
Joined 2003-04-16 00:00
23-year member
UID 1579
Gender Male
From 湖北仙桃
Status Offline
Thanks, Benshi, the one above is simple and effective.
vbdos itself can't set environment variables, but the system statement can return a DOS errorlevel, which can be called very well in a batch file, and is even better to use than environment variables.
下载
09年7月7日 更新
感谢网友 囧HQY 提供空间
Floor 10 Posted 2009-07-06 23:50 ·  中国 广东 揭阳 电信
高级用户
★★
Credits 774
Posts 293
Joined 2003-04-16 00:00
23-year member
UID 1579
Gender Male
From 湖北仙桃
Status Offline
A further question for Benshi: after wbat loads ccdos, there are problems when operating controls with the mouse. How can QBasic write a program to check whether the mouse driver is loaded?
Too many articles online call interrupts directly. That makes the generated file too large, and it's also inconvenient.
http://support.microsoft.com/kb/37882/zh-cn
http://support.microsoft.com/kb/28171/zh-cn
下载
09年7月7日 更新
感谢网友 囧HQY 提供空间
Floor 11 Posted 2009-07-07 04:53 ·  中国 江苏 苏州 电信
银牌会员
★★★
Credits 2,227
Posts 790
Joined 2005-01-27 00:00
21-year member
UID 35703
Gender Male
Status Offline
Please refer to "Porting QBASIC's interrupt calls in QB and extending absolute address calls" (http://www.cn-dos.net/forum/viewthread.php?tid=48086&sid=e1w9ca)
my major is english----my love is dos----my teacher is the buddha----my friends--how about U
Floor 12 Posted 2009-07-07 06:08 ·  中国 云南 昆明 联通
初级用户
★★
Credits 112
Posts 54
Joined 2007-06-18 22:47
19-year member
UID 91747
Gender Male
Status Offline
Floor 13 Posted 2010-11-19 15:11 ·  中国 福建 福州 福清市 电信
初级用户
Credits 134
Posts 17
Joined 2004-10-25 00:00
21-year member
UID 32901
Gender Male
Status Offline
Learning
Forum Jump: