Author Topic: example code to do ShellExecuteEx  (Read 2054 times)

0 Members and 1 Guest are viewing this topic.

chrisc

  • Guest
example code to do ShellExecuteEx
« 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?

Mike Lobanovsky

  • Guest
Re: example code to do ShellExecuteEx
« Reply #1 on: April 23, 2018, 02:34:45 PM »
Hi Chris,

1. Exactly what makes you want to use ShellExecuteEx() rather than simpler ShellExecute()?

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 showing that you real intent isn't just putting your own learning curve on somebody else's shoulders.

chrisc

  • Guest
Re: example code to do ShellExecuteEx
« Reply #2 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)


chrisc

  • Guest
Re: example code to do ShellExecuteEx
« Reply #3 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

Arnold

  • Guest
Re: example code to do ShellExecuteEx
« Reply #4 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

chrisc

  • Guest
Re: example code to do ShellExecuteEx
« Reply #5 on: April 24, 2018, 08:51:42 AM »
@Rolland

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


Arnold

  • Guest
Re: example code to do ShellExecuteEx
« Reply #6 on: April 24, 2018, 09:00:12 AM »
Yes, but you did too much.

chrisc

  • Guest
Re: example code to do ShellExecuteEx
« Reply #7 on: April 24, 2018, 09:13:10 AM »
Thanxx Roland