Share your advanced PureBasic knowledge/code with the community.
vanbeck
Enthusiast
Posts: 104 Joined: Mon Jun 11, 2007 1:31 pm
Location: The Swan
Post
by vanbeck » Mon Jun 11, 2007 2:09 pm
Hi all, my first post!
Total newbie here so forgive me if this is not the right place, or if it's already been posted as a better snippet.
Code: Select all
Procedure shell(file$)
;ShellExecute(hwnd, NullString,FILE,NullString,"",ShowMode)
If OpenLibrary(0, "shell32.dll")
shell = GetFunction(0, "ShellExecuteA")
CallFunctionFast(shell, 0, "", file$,"","",3)
CloseLibrary(0)
EndIf
EndProcedure
Just call the procedure with your filename as the only parameter.
ts-soft
Always Here
Posts: 5756 Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany
Post
by ts-soft » Mon Jun 11, 2007 2:24 pm
Is the same as RunProgram
PureBasic 5.73 |
SpiderBasic 2.30 |
Windows 10 Pro (x64) |
Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
vanbeck
Enthusiast
Posts: 104 Joined: Mon Jun 11, 2007 1:31 pm
Location: The Swan
Post
by vanbeck » Mon Jun 11, 2007 2:36 pm
Nope
- RunProgram would not let you run a shortcut, or an excel spreadsheet. Well unless it's changed, I couldn't get RunProgram to execute shortcuts or files.
Kiffi
Addict
Posts: 1504 Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9
Post
by Kiffi » Mon Jun 11, 2007 2:49 pm
RunProgram would not let you run a shortcut, or an excel spreadsheet.
... and my texteditor starts
... and Access starts
Greetings ... Kiffi
vanbeck
Enthusiast
Posts: 104 Joined: Mon Jun 11, 2007 1:31 pm
Location: The Swan
Post
by vanbeck » Mon Jun 11, 2007 3:06 pm
Strange one!
It does work with extensions, but for some reason it RunProgram won't work with shortcuts (.lnk).
Thanks for trying to steer me right though guys, I can be a stubborn git sometimes, soz.
PB
PureBasic Expert
Posts: 7581 Joined: Fri Apr 25, 2003 5:24 pm
Post
by PB » Mon Jun 11, 2007 3:12 pm
> for some reason it RunProgram won't work with shortcuts (.lnk)
Sure it does:
Code: Select all
RunProgram("c:\test.lnk") ; Works fine for me.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
Kale
PureBasic Expert
Posts: 3000 Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:
Post
by Kale » Mon Jun 11, 2007 6:40 pm
IIRC, RunProgram wraps ShellExecute, so its the same.
--Kale
ts-soft
Always Here
Posts: 5756 Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany
Post
by ts-soft » Mon Jun 11, 2007 6:56 pm
Kale wrote: IIRC, RunProgram wraps ShellExecute, so its the same.
Only if the first parameter not a executable, if the first parameter a executable its wraps the createprocess-api
PureBasic 5.73 |
SpiderBasic 2.30 |
Windows 10 Pro (x64) |
Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Trond
Always Here
Posts: 7446 Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway
Post
by Trond » Mon Jun 11, 2007 6:58 pm
ts-soft wrote: Kale wrote: IIRC, RunProgram wraps ShellExecute, so its the same.
Only if the first parameter not a executable, if the first parameter a executable its wraps the createprocess-api
Are you sure? I thought it used CreateProcess() always and then if it failed it used ShellExecute().
ts-soft
Always Here
Posts: 5756 Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany
Post
by ts-soft » Mon Jun 11, 2007 7:01 pm
>> Are you sure?
No. But wraps the shellexecute-api the create-process-api?
PureBasic 5.73 |
SpiderBasic 2.30 |
Windows 10 Pro (x64) |
Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
eJan
Enthusiast
Posts: 366 Joined: Sun May 21, 2006 11:22 pm
Location: Sankt Veit am Flaum
Post
by eJan » Mon Jun 11, 2007 7:30 pm
@vanbeck a shorter way:
Code: Select all
ShellExecute_(#Null, #Null, "C:\Backup Job.bms", #Null, #Null, #SW_SHOWNORMAL)
vanbeck
Enthusiast
Posts: 104 Joined: Mon Jun 11, 2007 1:31 pm
Location: The Swan
Post
by vanbeck » Tue Jun 12, 2007 7:28 am
Ahh, cool, I was wondering how to represent null in PB.
Thanks for all the input, sorry for the pointless post!
Trond
Always Here
Posts: 7446 Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway
Post
by Trond » Tue Jun 12, 2007 10:28 am
Ahh, cool, I was wondering how to represent null in PB.
Like this: 0. #Null is just a constant that is replaced with 0 when the program is compiled.