|
-
December 1st, 2008, 06:30 PM
#1
ShellExecuteEx()
hello,
i keep getting errors when i run the code from
http://www.codeguru.com/forum/showthread.php?t=302501
i added the appropiate header files, so my code is
Code:
#include <windows.h>
int main() {
SHELLEXECUTEINFO ExecuteInfo;
memset(&ExecuteInfo, 0, sizeof(ExecuteInfo));
ExecuteInfo.cbSize = sizeof(ExecuteInfo);
ExecuteInfo.fMask = 0;
ExecuteInfo.hwnd = 0;
ExecuteInfo.lpVerb = "open"; // Operation to perform
ExecuteInfo.lpFile = "c:\\windows\\notepad.exe"; // Application name
ExecuteInfo.lpParameters = "c:\\example.txt"; // Additional parameters
ExecuteInfo.lpDirectory = 0; // Default directory
ExecuteInfo.nShow = SW_SHOW;
ExecuteInfo.hInstApp = 0;
if(ShellExecuteEx(&ExecuteInfo) == FALSE)
// Could not start application -> call 'GetLastError()'
return 0;
}
the errors i get are:
1>------ Build started: Project: aaa, Configuration: Debug Win32 ------
1>Compiling...
1>aaa.cpp
1>c:\documents and settings\z\desktop\c++\aaa\aaa\aaa.cpp(12) : error C2440: '=' : cannot convert from 'const char [5]' to 'LPCWSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\documents and settings\z\desktop\c++\aaa\aaa\aaa.cpp(13) : error C2440: '=' : cannot convert from 'const char [23]' to 'LPCWSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\documents and settings\z\desktop\c++\aaa\aaa\aaa.cpp(14) : error C2440: '=' : cannot convert from 'const char [15]' to 'LPCWSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>Build log was saved at "file://c:\Documents and Settings\z\Desktop\c++\aaa\aaa\Debug\BuildLog.htm"
1>aaa - 3 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
what is wrong with my code?
and what do i have to do to fix it?
im also using windows XP
thanks for help in advance, zac
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|