-
executing program....
hi,
2. I have problem when executing program from windows, I use: system("c:\\windows\\Notepad.exe"); and all is ok but that stupid dos box appears when notepad is executed, now the question, how to execute program without dos box???
2. I used ShellExecute but got an error while compiling:
"passing `const char *' as argument 1 of `ShellExecuteA(HWND__ *, const CHAR *, const CHAR *, const CHAR *, const CHAR *, int)'" so whats the syntax of ShellExecute ??
-
ok I solved the problem, sorry for messing up :)
ShellExecute(HWND_DESKTOP,"open","c:\\windows\\Not epad.exe",NULL,NULL,SW_SHOWNORMAL);
-
You can also use WinExec("notepad.exe", SW_SHOWNORMAL);
or WinExec("notepad.exe path_file.txt", SW_SHOWNORMAL);
-
of course i can, thanks ;)
-
WinExec( ) is for 16-bit compatibility though... You should really start using CreateProcess for the newer Windows OS's...
-
so what is the syntax of CreateProcess?? :) and what library to use it with (*.h) :)
-
Code:
BOOL CreateProcess(
LPCTSTR lpApplicationName, // name of executable module
LPTSTR lpCommandLine, // command line string
LPSECURITY_ATTRIBUTES lpProcessAttributes, // SD
LPSECURITY_ATTRIBUTES lpThreadAttributes, // SD
BOOL bInheritHandles, // handle inheritance option
DWORD dwCreationFlags, // creation flags
LPVOID lpEnvironment, // new environment block
LPCTSTR lpCurrentDirectory, // current directory name
LPSTARTUPINFO lpStartupInfo, // startup information
LPPROCESS_INFORMATION lpProcessInformation // process information
);
Imported from Kernel32 (so you dont need any more libs that a standard project) and defined under windows.h
Its a complex and very powerful func....
For Shell Execution I prefer...er...ShellExecute() as it can run documents and launch a program based on extension settings