Executing a programm from my application
-
Hello guys, I'm trying to execute a *.exe file from an own win api. Of course I looked through the internet but all i could find was ShellExecute() and CreateProcess() which, for any reason, don't work in VC++2008. Do I need to include any special library files or headers to get access to these functions, or is there another way to start a program from my win api? Thanks ans best wishes, Manfred
-
Hello guys, I'm trying to execute a *.exe file from an own win api. Of course I looked through the internet but all i could find was ShellExecute() and CreateProcess() which, for any reason, don't work in VC++2008. Do I need to include any special library files or headers to get access to these functions, or is there another way to start a program from my win api? Thanks ans best wishes, Manfred
Hi, if you want to create a process, maybe you should read up on the Process class? :)
Luc Pattyn [Forum Guidelines] [My Articles]
Voting for dummies? No thanks. X|
-
Hello guys, I'm trying to execute a *.exe file from an own win api. Of course I looked through the internet but all i could find was ShellExecute() and CreateProcess() which, for any reason, don't work in VC++2008. Do I need to include any special library files or headers to get access to these functions, or is there another way to start a program from my win api? Thanks ans best wishes, Manfred
Austrian_Programmer wrote:
Do I need to include any special library files or headers to get access to these functions
ShellExecute() Header - shellapi.h Import library - shell32.lib CreateProcess() Header - Declared in Winbase.h; include Windows.h. Library - Use Kernel32.lib.
-
Austrian_Programmer wrote:
Do I need to include any special library files or headers to get access to these functions
ShellExecute() Header - shellapi.h Import library - shell32.lib CreateProcess() Header - Declared in Winbase.h; include Windows.h. Library - Use Kernel32.lib.
Thanks, but you need windows.h in both cases. I tried the ShellExecute() function with the included header and library, but nothing happens, the specified program didn't start.
#pragma once #pragma comment(lib, "shell32.lib") #include #include // ... char *pcOp = "open"; char *pcPath = "calc.exe"; ShellExecute(NULL, (LPCWSTR)pcOp, (LPCWSTR)pcPath, NULL, NULL, SW_SHOWNORMAL);
As I run this code I didn't get any error messages but nothing happened. What am I doing wrong? -
Thanks, but you need windows.h in both cases. I tried the ShellExecute() function with the included header and library, but nothing happens, the specified program didn't start.
#pragma once #pragma comment(lib, "shell32.lib") #include #include // ... char *pcOp = "open"; char *pcPath = "calc.exe"; ShellExecute(NULL, (LPCWSTR)pcOp, (LPCWSTR)pcPath, NULL, NULL, SW_SHOWNORMAL);
As I run this code I didn't get any error messages but nothing happened. What am I doing wrong? -
Thanks, but you need windows.h in both cases. I tried the ShellExecute() function with the included header and library, but nothing happens, the specified program didn't start.
#pragma once #pragma comment(lib, "shell32.lib") #include #include // ... char *pcOp = "open"; char *pcPath = "calc.exe"; ShellExecute(NULL, (LPCWSTR)pcOp, (LPCWSTR)pcPath, NULL, NULL, SW_SHOWNORMAL);
As I run this code I didn't get any error messages but nothing happened. What am I doing wrong?Austrian_Programmer wrote:
ShellExecute(NULL, (LPCWSTR)pcOp, (LPCWSTR)pcPath, NULL, NULL, SW_SHOWNORMAL); As I run this code I didn't get any error messages but nothing happened. What am I doing wrong?
Casting char*s to wchar_t*s is not good. You shouldn't use casts unless absolutely necessary. If it doesn't compile without the casts, then I recommend looking at the types involved before covering the problem with a cast. Mark