|
-
Feb 18th, 2002, 09:45 AM
#1
Thread Starter
Member
ShellExecuteEx help!
Hi,
I have this 'slight' problem using ShellExecuteEx (after having tried all alternatives: CreateProcess, Shell(), ShellExecute)
When I feed it with a filename for which an association exists, it's no problem. (.txt - Notepad starts and runs...)
But when I feed it with an executable, I can barely see the outline of the window (so it has been started!), before Windows mysteriously decides to immediately close it. I end up with a pid of a non-existent process...
Can someone please help? Would it be part of NT4 workstation restrictions?
Here's the code:
Code:
Public Declare Function ShellExecuteEx Lib "shell32.dll" (ShellExecuteInfo As ShellExecuteInfoType) As Long
Public Const SEE_MASK_INVOKEIDLIST = &HC
Public Const SEE_MASK_NOCLOSEPROCESS = &H40
Public Const SEE_MASK_FLAG_NO_UI = &H400
Private Type ShellExecuteInfoType
cbSize As Long
fMask As Long
hwnd As Long
lpVerb As String
lpFile As String
lpParameters As String
lpDirectory As String
nShow As Long
hInstApp As Long
lpIDList As Long
lpClass As String
hkeyClass As Long
dwHotKey As Long
hIcon As Long
hProcess As Long
End Type
Public Function StartApplication(ApplicationName As String) As Long
Dim theShellExecuteInfo As ShellExecuteInfoType
Dim ret As Long
Dim hwnd As Long
With theShellExecuteInfo
.cbSize = Len(theShellExecuteInfo)
.fMask = SEE_MASK_NOCLOSEPROCESS Or SEE_MASK_INVOKEIDLIST Or _
SEE_MASK_FLAG_NO_UI
.hwnd = Me.hWnd
.lpVerb = "open"
.lpFile = ApplicationName & vbNullChar
.lpParameters = vbNullChar
.lpDirectory = vbNullChar
.nShow = 0
.hInstApp = 0
.lpIDList = 0
End With
ret = ShellExecuteEx(theShellExecuteInfo)
StartApplication = theShellExecuteInfo.hProcess
End Function
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|