中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-09-14 23:50
47,812 topics / 349,917 posts / today 0 new / 48,268 members
DOS开发编程 & 发展交流 (开发室) » Quick BASIC Program to Automatically Detect Whether a Chinese Character Support System Is Loaded
Printable Version  3,092 / 12
Floor1 MYS Posted 2004-02-27 00:00
元老会员 Posts 1,637 Credits 5,170 From 广东佛山
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
Floor2 Wengier Posted 2004-02-28 00:00
系统支持 Posts 10,521 Credits 27,736
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.

Floor3 Kinglion Posted 2004-03-02 00:00
铂金会员 Posts 1,924 Credits 5,798 From 金獅電腦軟體工作室
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.
Floor4 Kinglion Posted 2004-03-21 00:00
铂金会员 Posts 1,924 Credits 5,798 From 金獅電腦軟體工作室
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




Floor5 xugaohui Posted 2009-07-05 10:57
高级用户 Posts 293 Credits 774 From 湖北仙桃
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 ]
Floor6 本是 Posted 2009-07-05 12:46
银牌会员 Posts 790 Credits 2,227
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
Floor7 xugaohui Posted 2009-07-05 13:10
高级用户 Posts 293 Credits 774 From 湖北仙桃
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 ]
Floor8 本是 Posted 2009-07-06 00:19
银牌会员 Posts 790 Credits 2,227
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
Floor9 xugaohui Posted 2009-07-06 04:45
高级用户 Posts 293 Credits 774 From 湖北仙桃
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.
Floor10 xugaohui Posted 2009-07-06 23:50
高级用户 Posts 293 Credits 774 From 湖北仙桃
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
Floor11 本是 Posted 2009-07-07 04:53
银牌会员 Posts 790 Credits 2,227
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)
Floor12 byxyk Posted 2009-07-07 06:08
初级用户 Posts 54 Credits 112
Floor13 netreg Posted 2010-11-19 15:11
初级用户 Posts 17 Credits 134
Learning
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023