Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Prevent manual invocation of COM EXE?
Message
From
23/10/2012 14:53:44
 
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Miscellaneous
Thread ID:
01555563
Message ID:
01555568
Views:
48
>We have something to solve this issue, we have a launcher program that will do some checkings, for example if the user has enough right to launch said program, but of course if they run the exe directly this check will not be performed, so we check that the exe has been started from our launcher, the code is
>
>
>	* The only valid call is from Launcher.EXE for it verified user rights, terminate otherwise
>	if not Inlist(Nvl(Lower(getParentProgram()), ''), 'x:\foxv\prog\launcher.exe', '\\skyapps\apps\foxv\prog\launcher.exe')
>		Messagebox('This program cannot run independently' + Chr(13) + 'You must use the Local Launcher application, contact IT for directions', 64, 'Direct access disabled!')
>		return .f.
>	endif
>
>
>And the getParentProgram is:
>
>
>local loLocator, loWMI, loProcesses, loProcess, lnProgID, loParentProcesses, loParentProcess, lcParent
>
>declare integer GetCurrentProcessId in WIN32API
>
>lcParent	= null
>lnProgID	= GetCurrentProcessId()
>loLocator	= CREATEOBJECT('WBEMScripting.SWBEMLocator')
>loWMI		= loLocator.ConnectServer()
>loProcesses	= loWMI.ExecQuery([SELECT * FROM Win32_Process WHERE ProcessId = ] + Transform(lnProgID))
>
>For each loProcess in loProcesses
>	loParentProcesses	= loWMI.ExecQuery([SELECT * FROM Win32_Process WHERE ProcessId = ] + Transform(loProcess.ParentProcessID))
>	for each loParentProcess in loParentProcesses
>		lcParent		= loParentProcess.ExecutablePath
>	endfor
>endfor
>
>return lcParent
>
This is a fancy approach. Thanks for sharing it.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform