- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
In a QWIN app I need to copy all files from D:TODOS
to C:TODOS. Could not find how to do it using Fortran
so I made a DOS batch file COPIA_TODOS.BAT :
@ECHO OFF
XCOPY D:TODOS*.* C:TODOS
EXIT
and in my Fortran source used
Iret=SYSTEMQQ('COPIA_TODOS')
It works but the ugly black DOS prompt windows shows
for some seconds then closes by itself.
I tryed using CreateProcess but the DOS windows then
remains open and must be closed " by hand". Same with RUNQQ.
I used CreateProcess as below:
type (T_STARTUPINFO) si
type (T_PROCESS_INFORMATION) pi
call ZeroMemory (LOC(si), SIZEOF(si))
call ZeroMemory (LOC(pi), SIZEOF(pi))
si%cb = SIZEOF (si)
si%dwFlags = STARTF_USESTDHANDLES
si%wShowWindow = SW_SHOWMAXIMIZED
si%dwFlags = IOR (STARTF_USESHOWWINDOW, si%dwFlags)
IRET=CreateProcessNULL,'COPIA_TODOS.BAT' & (,NULL,NULL,FALSE,0,NULL,NULL,si,pi)
IRET=WaitForSingleObject(pi%hProcess,INFINITE)
IRET=CloseHandle(pi%hThread)
IRET=CloseHandle(pi%hProcess)
Not using WaitForSingleObject made no diference.
Is there a way of making the copies using Fortran ?
Did I make a mistake in some CreateProcess parameter?
I am using W98SE and CVF Prof Ed 6.6B.
Thanks
Geraldo
In a QWIN app I need to copy all files from D:TODOS
to C:TODOS. Could not find how to do it using Fortran
so I made a DOS batch file COPIA_TODOS.BAT :
@ECHO OFF
XCOPY D:TODOS*.* C:TODOS
EXIT
and in my Fortran source used
Iret=SYSTEMQQ('COPIA_TODOS')
It works but the ugly black DOS prompt windows shows
for some seconds then closes by itself.
I tryed using CreateProcess but the DOS windows then
remains open and must be closed " by hand". Same with RUNQQ.
I used CreateProcess as below:
type (T_STARTUPINFO) si
type (T_PROCESS_INFORMATION) pi
call ZeroMemory (LOC(si), SIZEOF(si))
call ZeroMemory (LOC(pi), SIZEOF(pi))
si%cb = SIZEOF (si)
si%dwFlags = STARTF_USESTDHANDLES
si%wShowWindow = SW_SHOWMAXIMIZED
si%dwFlags = IOR (STARTF_USESHOWWINDOW, si%dwFlags)
IRET=CreateProcessNULL,'COPIA_TODOS.BAT' & (,NULL,NULL,FALSE,0,NULL,NULL,si,pi)
IRET=WaitForSingleObject(pi%hProcess,INFINITE)
IRET=CloseHandle(pi%hThread)
IRET=CloseHandle(pi%hProcess)
Not using WaitForSingleObject made no diference.
Is there a way of making the copies using Fortran ?
Did I make a mistake in some CreateProcess parameter?
I am using W98SE and CVF Prof Ed 6.6B.
Thanks
Geraldo
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve recently posted an example using FINDFILEQQ for enumerating all files in a directory. (There's also Win32 equivalent FindFirstFile/FindNextFile/FindClose). You should just add a call to CopyFile API (take care about char(0) termination of strings).
If there's need to copy the subdirectories as well, well, please repost...
Your approach doesn't work because COPIA_TODOS.bat is not an executable, but a command interpreter script. You must invoke command-line interpreter (cmd.exe on Winnt, command.com on Win9x) and tell it to execute the .bat file. If I recall correctly, the command is "cmd /k copia_todos.bat", and that's what should go as lpCommandLine argument. But using library calls is far nicer.
Jugoslav
If there's need to copy the subdirectories as well, well, please repost...
Your approach doesn't work because COPIA_TODOS.bat is not an executable, but a command interpreter script. You must invoke command-line interpreter (cmd.exe on Winnt, command.com on Win9x) and tell it to execute the .bat file. If I recall correctly, the command is "cmd /k copia_todos.bat", and that's what should go as lpCommandLine argument. But using library calls is far nicer.
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
While the CopyFile API is probably the standard, you should also check out XCOPY.exe. This has been on all my computers in the PATH, from Win 95 thru Win 2k. It offers a very useful array of optional switches (e.g. /D to copy only if newer). Open a DOS window and enter XCOPY /? for options. Don't forget the double quotes around long file names, and the terminating null string.
To use, enter something like:
Greg
To use, enter something like:
iRet = ShellExecute(hInstance, NULL, 'xcopy.exe'C, '/Y /D "' // & PathID // 'OldFile*.*" "' // trim(NewDirectory) // '"'C, NULL, SW_HIDE)
Greg
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Using
si%wShowWindow = SW_SHOWMINIMIZED
CreateProcess(NULL,"COMMAND.COM /C COPIA_TODOS.BAT", &
NULL,NULL,FALSE,0,NULL,NULL,si,pi)
runs COPIA_TODOS.BAT minimized, without the black DOS window.
Greg,
I used xcopy in the bat and later I will try the other schemes both of you suggested.
Thanks
Geraldo
si%wShowWindow = SW_SHOWMINIMIZED
CreateProcess(NULL,"COMMAND.COM /C COPIA_TODOS.BAT", &
NULL,NULL,FALSE,0,NULL,NULL,si,pi)
runs COPIA_TODOS.BAT minimized, without the black DOS window.
Greg,
I used xcopy in the bat and later I will try the other schemes both of you suggested.
Thanks
Geraldo

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page