Hi,
Is it possible to check (in your PB application) how a executable has been launched, i.e. "double click", "command prompt" or "run"?
M$ records everything in registry, so I shouldn't be supprised if they record that kind of stuff.
Do they?
If not - is there another way to find out this information?
Is it possible to check how a executable has been launched?
-
- Addict
- Posts: 1126
- Joined: Wed Oct 15, 2003 12:40 am
- Location: Sweden
- Contact:
Is it possible to check how a executable has been launched?

(\__/)
(='.'=) This is Bunny. Copy and paste Bunny into your
(")_(") signature to help him gain world domination.
If you control the install, can you make each method send a command argument? Eg:
Too simplistic?
Code: Select all
C:\mypath\myprog.exe shortcut
@}--`--,-- A rose by any other name ..
-
- Addict
- Posts: 1126
- Joined: Wed Oct 15, 2003 12:40 am
- Location: Sweden
- Contact:
You could check the parent process like that:
What it does:
1. It creates an invisible window
2. It determines the parent process of that window
Code: Select all
Procedure GetParentProcess(hwnd.l)
Protected hwndp.l, pid.l, snap.l, pinfo.PROCESSENTRY32,parentinfo.PROCESSENTRY32
GetWindowThreadProcessId_(hwnd, @pid)
snap = CreateToolhelp32Snapshot_(#TH32CS_SNAPPROCESS,0)
If snap
pinfo\dwSize=SizeOf(PROCESSENTRY32);
If Process32First_(snap, @pinfo)
While Process32Next_(snap, @pinfo)
If pid = pinfo\th32ProcessID
CloseHandle_(snap);
snap = CreateToolhelp32Snapshot_(#TH32CS_SNAPPROCESS,0)
If snap
parentinfo\dwSize=SizeOf(PROCESSENTRY32);
If Process32First_(snap, @parentinfo)
While Process32Next_(snap, @parentinfo)
If pinfo\th32ParentProcessID = parentinfo\th32ProcessID
CloseHandle_(snap);
MessageRequester("Program...","started via "+Chr(39)+PeekS(@parentinfo\szExeFile)+Chr(39))
EndIf
Wend
EndIf
CloseHandle_(snap);
EndIf
EndIf
Wend
EndIf
CloseHandle_(snap);
EndIf
EndProcedure
OpenWindow(0,0,0,0,0,"proc",#PB_Window_Invisible)
GetParentProcess(WindowID(0))
1. It creates an invisible window
2. It determines the parent process of that window
Last edited by real on Fri May 05, 2006 11:54 am, edited 1 time in total.
Got this from here: http://www.catch22.net/tuts/undoc01.asp
Code: Select all
; Returns TRUE if started through a shortcut, FALSE if not.
#STARTF_TITLESHORTCUT = $800
Procedure StartedFromShortcut()
GetStartupInfo_(@si.STARTUPINFO)
If si\dwFlags&#STARTF_TITLESHORTCUT
ProcedureReturn #True
EndIf
ProcedureReturn #False
EndProcedure
MessageRequester("Started from shortcut?:", Str(StartedFromShortcut()))
El_Choni