The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: azdps on June 03, 2008, 06:00:46 AM

Title: shellexecute problem
Post by: azdps on June 03, 2008, 06:00:46 AM
Everytime I use shellexecute to start explorer.exe my documents window opens up. This applies to WinExec and CreateProcess as well. When windows explorer.exe isnt running the same thing happens.


.586
.model flat, stdcall
option casemap :none

   include        /masm32/include/windows.inc
   include        /masm32/include/kernel32.inc
   include        /masm32/include/shell32.inc
     
   includelib     /masm32/lib/kernel32.lib
   includelib     /masm32/lib/shell32.lib

 
   .data
      FilePath db "c:\windows\explorer.exe",0
      Open     db "open",0
   
   .code
start:

      invoke ShellExecute,0,addr Open,Addr FilePath,0,0,0

invoke ExitProcess,0
end start

Title: Re: shellexecute problem
Post by: zooba on June 03, 2008, 07:40:01 AM
What are you expecting to happen? The default startup path is your documents folder. You can specify a path to lpDirectory (the second last parameter) if you would prefer it to start somewhere else.

Cheers,

Zooba :U
Title: Re: shellexecute problem
Post by: PBrennick on June 03, 2008, 09:26:29 AM
azdps,
Exactly what are you trying to do because your description sounds acceptable to me as zooba has stated. Are you trying for Internet Explorer? If so, there are a couple of problems here. One, is the difference between explorer.exe and iexplore.exe. The following works just fine.


.586
.model flat, stdcall
option casemap :none

include /masm32/include/windows.inc
include /masm32/include/kernel32.inc
include /masm32/include/shell32.inc

includelib /masm32/lib/kernel32.lib
includelib /masm32/lib/shell32.lib


.data
; FilePath db "c:\windows\explorer.exe",0
FilePath db "c:\Program Files\Internet Explorer\",0
FileName db "IEXPLORE.EXE", 0
Open db "open",0

.code
start:

invoke ShellExecute,0,addr Open,addr FileName,0,addr FilePath,SW_SHOW

invoke ExitProcess,0
end start


If, indeed, you wish to explore your HD, use my example line of ShellExecute to show you how it should be set up. The FilePath should be replaced with the particular folder that you wish to open.
Paul
Title: Re: shellexecute problem
Post by: azdps on June 03, 2008, 02:34:06 PM
Alright I was doing everything right orginally but then changed to the code I posted because things were just not working out. The problem this whole time was that I did not have the editor setup to recognize spaces in a path name. So if I had a folder on the desktop named NEW FOLDER when I clicked on run exe in my editor it wouldn't execute the executable. Since my test program did not have a gui I didn't notice that the executable wouldnt actually run. Because I knew your code had to be right I realized the problem was somewhere else than my code. Thanks for the help.