中国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-10-31 11:28
47,815 topics / 349,930 posts / today 0 new / 48,290 members
DOS开发编程 & 发展交流 (开发室) » How to read and write DOS variables in C?
Printable Version  1,818 / 3
Floor1 kang2008 Posted 2008-12-27 22:12
初级用户 Posts 14 Credits 28
How does C read and write DOS variables?
Or, how can a program written in C read/modify DOS variables or assign the return value to a DOS variable?

For example, there is a variable in DOS: vCdrom=D:, but I just want the first character. C can use the left() function to intercept, but there seems to be no such command in DOS.
Floor2 kemyliu Posted 2009-01-07 18:05
新手上路 Posts 8 Credits 16
DOS doesn't have such a function. Write a conversion program in C.
Floor3 zhgwbzhd Posted 2009-01-08 11:09
高级用户 Posts 187 Credits 506
I don't understand what you mean.
But it can be implemented as follows.
For example, you have a program A.exe, and after it finishes, it returns a value, such as maybe 1 or 2.
Execute different programs B.exe or C.exe according to your return value.

It can be implemented through batch processing.

A.exe(Execute A)
if errorlevel 2 goto L_2
if errorlevel 1 goto L_1
goto L_end
:L_2
C.exe
goto L_end
:L_1
B.exe
goto L_end
:L_end
Floor4 hepu Posted 2009-01-16 15:49
新手上路 Posts 6 Credits 11
Try the main program return value.

int main()
{
int x=0;
....

retun x;
}
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023