Coding for DOS

Reply

Join Date: Mar 2009
Posts: 2
Reputation: vinitt88 is an unknown quantity at this point 
Solved Threads: 0
vinitt88 vinitt88 is offline Offline
Newbie Poster

Coding for DOS

 
0
  #1
Mar 19th, 2009
Hi,
I am trying to develop a DOS-like system which will be able to do all minor functions like cd.. cd/ and changing to sub directories.

Guys I am stuck in how to find a single path for many files.....

Thanx in ADVANCE
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 357
Reputation: death_oclock will become famous soon enough death_oclock will become famous soon enough 
Solved Threads: 37
death_oclock's Avatar
death_oclock death_oclock is offline Offline
Posting Whiz

Re: Coding for DOS

 
0
  #2
Mar 19th, 2009
Are you trying to emulate a DOS environment using C? Post the relevant code you have already, what it is supposed to do, and what it is doing wrong.
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 2
Reputation: vinitt88 is an unknown quantity at this point 
Solved Threads: 0
vinitt88 vinitt88 is offline Offline
Newbie Poster

Re: Coding for DOS

 
0
  #3
Mar 20th, 2009
Originally Posted by death_oclock View Post
Are you trying to emulate a DOS environment using C? Post the relevant code you have already, what it is supposed to do, and what it is doing wrong.

yaa thats correct I need to emulate DOS environment in C.

I m yet to start the exact coding part
I am confused in system() function and windows.h files

I need to make a file which when executed must take you to the respective directory or sub directory of a given directory.

File Handling will be an alternative but I would have to make links to all ssub directories when I would like to access all of them one at a time.

This according to me requires handles not pointers.

I am confused in this concept!!
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,359
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1464
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: Coding for DOS

 
0
  #4
Mar 20th, 2009
If you want to write your own mini-dos then you can not use the system() function for anything.

You can get list of files and sub-directories in MS-Windows by using the FindFirstFile() and FindNextFile() win32 api functions (look them up with google to find exact syntax.) You can find all sorts of examples on the net, just use google.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 255
Reputation: Hiroshe is a jewel in the rough Hiroshe is a jewel in the rough Hiroshe is a jewel in the rough Hiroshe is a jewel in the rough 
Solved Threads: 16
Hiroshe's Avatar
Hiroshe Hiroshe is offline Offline
Posting Whiz in Training

Re: Coding for DOS

 
0
  #5
Mar 22nd, 2009
Are you trying to make a shell that will run ontop of windows executing windows/dos programs? Just keep track of your current directory youself in an extra variable. Example:
  1. cd c:\myprogram
The current directory variable now holds: c:\myprogram\
(remember to check if it exsists)
  1. main
Would first check to see if c:\myprogram\main.exe exsisted.
If it did, run system("c:\myprogram\main.exe");
if not, check to see if c:\dos\main.exe exsisted.
If it did, run system("c:\dos\main.exe");
If not, print "file could not be found."
Will execute system("dir c:\myprogram\")
Last edited by Hiroshe; Mar 22nd, 2009 at 1:13 pm.
"Sometimes, when I lie in bed at night and look up at the stars, I think to myself, "Man! I really need to fix that roof."-Jack Handy
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 241
Reputation: ssharish2005 is on a distinguished road 
Solved Threads: 20
ssharish2005's Avatar
ssharish2005 ssharish2005 is offline Offline
Posting Whiz in Training

Re: Coding for DOS

 
0
  #6
Mar 22nd, 2009
Originally Posted by vinitt88 View Post
Hi,
I am trying to develop a DOS-like system which will be able to do all minor functions like cd.. cd/ and changing to sub directories.

Guys I am stuck in how to find a single path for many files.....

Thanx in ADVANCE
Well, if you are trying to executing those DOS command through your code. The only piece of work which you will have to do is to format the command and then look at the directory structure and then pass the formatted command to the system function. That should probably simulate all the simple commands that you want.

But then again, if your using the system function you haven't really achieved of anything writing your version of Windows DOS!

-ssharish
"Any fool can know, point is to understand"
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,359
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1464
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: Coding for DOS

 
0
  #7
Mar 22nd, 2009
The problem with using the system() functions to do a lot of things is that whever you wanted it to do just disappears as soon as the system() function finishes. For example: lets say you want to change directories to c:\windows so you issue the command system(cd c:\\windows"); The system() function will execute the dos command, but as soon as system() returns to your program the program's current working directory will not have changed. To make such a command permanent in your program, it needs to issue equivalent C functions, in this case _chdir("c:\\windows");
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC