noob alert part 2 !! ShellExec function.
-
hello, I am a begginer. i'm experimenting with a shellexec funtion to try and launch various things from my simple dialog based MFC application. Things like web pages, exe's, and files. I plan on just mapping them to a simple button. can anyone explain (in newb terms) how to get this function to work properly?? How to implement it and where exactly im supposed to add this code?? I would really appreciate any help, Thanks
-
hello, I am a begginer. i'm experimenting with a shellexec funtion to try and launch various things from my simple dialog based MFC application. Things like web pages, exe's, and files. I plan on just mapping them to a simple button. can anyone explain (in newb terms) how to get this function to work properly?? How to implement it and where exactly im supposed to add this code?? I would really appreciate any help, Thanks
In the resource editor, add a button to the dialog Double click on the button. This adds a method to the dialog class Add code for the handler. From MSDN: HINSTANCE ShellExecute( HWND hwnd, LPCTSTR lpOperation, LPCTSTR lpFile, LPCTSTR lpParameters, LPCTSTR lpDirectory, INT nShowCmd ); hwnd - 0 - don't worry about the parent window, set to NULL lpOperation - "open" - open something lpFile - "your.file" - the file or URL you want to open lpParameters - "" - unless you need to pass in cmd line params lpDirectory - "" - unless you care what directory the launched app starts in nShowCmd - SW_SHOWNORMAL - this will be okay most of the time ShellExecute(0,"open","http://www.codeproject.com","","",SW_SHOWNORMAL);
If you can keep you head when all about you Are losing theirs and blaming it on you; If you can dream - and not make dreams your master; If you can think - and not make thoughts you aim; Yours is the Earth and everything that's in it. Rudyard Kipling
-
In the resource editor, add a button to the dialog Double click on the button. This adds a method to the dialog class Add code for the handler. From MSDN: HINSTANCE ShellExecute( HWND hwnd, LPCTSTR lpOperation, LPCTSTR lpFile, LPCTSTR lpParameters, LPCTSTR lpDirectory, INT nShowCmd ); hwnd - 0 - don't worry about the parent window, set to NULL lpOperation - "open" - open something lpFile - "your.file" - the file or URL you want to open lpParameters - "" - unless you need to pass in cmd line params lpDirectory - "" - unless you care what directory the launched app starts in nShowCmd - SW_SHOWNORMAL - this will be okay most of the time ShellExecute(0,"open","http://www.codeproject.com","","",SW_SHOWNORMAL);
If you can keep you head when all about you Are losing theirs and blaming it on you; If you can dream - and not make dreams your master; If you can think - and not make thoughts you aim; Yours is the Earth and everything that's in it. Rudyard Kipling
hi, thank you very much for the info! you got me on the right track.. however when i compile i get an error that reads: error C2373: 'ShellExecuteA' : redefinition; different type modifiers i dont know if i put all of the code in the right spot, i added it all under the button function:
void CShell2Dlg::OnButton1() { // TODO: Add your control notification handler code here HINSTANCE ShellExecute( HWND hwnd, LPCTSTR lpOperation, LPCTSTR lpFile, LPCTSTR lpParameters, LPCTSTR lpDirectory, INT nShowCmd ); ShellExecute(0,"open","http://www.codeproject.com","","",SW_SHOWNORMAL); }
--later