Oxygen Basic

Programming => Problems & Solutions => Topic started by: chrisc on April 23, 2018, 12:49:30 PM

Title: example code to do ShellExecuteEx
Post by: chrisc on April 23, 2018, 12:49:30 PM
Hello

i need an example code to do ShellExecuteEx() api 
can some one show me how to do it?
Title: Re: example code to do ShellExecuteEx
Post by: Mike Lobanovsky on April 23, 2018, 02:34:45 PM
Hi Chris,

1. Exactly what makes you want to use ShellExecuteEx() (https://msdn.microsoft.com/en-us/library/windows/desktop/bb762154(v=vs.85).aspx) rather than simpler ShellExecute() (https://msdn.microsoft.com/en-us/library/windows/desktop/bb762153(v=vs.85).aspx)?

2. Have you already seen ShellExecute.o2bas in the \OxygenBasic\examples\System\ folder?

3. Have you done any homework of your own yet trying to use ShellExecuteEx() but failing to do so? Sometimes it's faster to get someone's response (https://www.google.com/search?ei=dV7eWvaVM8zHwALR6Yf4Cw&q=how+to+ask+forum+questions+correctly&oq=how+to+ask+forum+questions+correctly&gs_l=psy-ab.12...37196.37896.0.40202.3.3.0.0.0.0.80.230.3.3.0....0...1c..64.psy-ab..0.0.0....0.gi33O2jxwE0) showing that you real intent isn't just putting your own learning curve on somebody else's shoulders.
Title: Re: example code to do ShellExecuteEx
Post by: chrisc on April 24, 2018, 03:50:27 AM
Thanxx a lot Mike

i was just looking for a way to execute a notepad to open a txt file.  i found the way as below

Code: [Select]
' RunNotepad.o2bas
' Runs a notepad to display a text file

$ filename "RunNotepad.exe"
uses RTL64


%SW_SHOWNORMAL = 1

! ShellExecute alias "ShellExecuteA" lib "Shell32.dll" _
(sys Hwnd, string operation,file,parameters,directory,sys ShowCmd) as sys

 
         ' Display text file using notepad
      Long lRes
      lRes = ShellExecute(0, "", "Notepad.exe",  "crepdata.txt" , "", %SW_SHOWNORMAL)

Title: Re: example code to do ShellExecuteEx
Post by: chrisc on April 24, 2018, 03:55:59 AM
BTW Mike

what is the difference between  ShellExecuteEx() and ShellExecute()?

i'm only a beginner programmer and i don't have a college degree like you have
so i do really need to learn the ropes to survive
Title: Re: example code to do ShellExecuteEx
Post by: Arnold on April 24, 2018, 08:28:41 AM
Hi Chris,

would you try this little experiment? Open Oxide.exe. Copy this little text into the editor, nothing else:

Code: OxygenBasic
  1. uses corewin
  2.  
  3. ShellExecute(0, "", "Notepad.exe",  "crepdata.txt" , "", SW_SHOWNORMAL)
  4.  

Press F5 or use the Menu option: Compile/Run program directly. What will happen? What did you notice?

Do you not have access to the Win32 help file? Here you will find the explanation of the WinApi functions ShellExecute and ShellExecuteEx. You could also download the complete Microsoft Windows SDK/PSDK with the documentation, but for me this is too much:
https://en.wikipedia.org/wiki/Microsoft_Windows_SDK

Roland
Title: Re: example code to do ShellExecuteEx
Post by: chrisc on April 24, 2018, 08:51:42 AM
@Rolland

i have already written the code in reply #2 above ?

Title: Re: example code to do ShellExecuteEx
Post by: Arnold on April 24, 2018, 09:00:12 AM
Yes, but you did too much.
Title: Re: example code to do ShellExecuteEx
Post by: chrisc on April 24, 2018, 09:13:10 AM
Thanxx Roland