|
-
August 5th, 1999, 07:03 AM
#1
ShellExecute and "properties" verb
I found a "solution" for my property dialog question.
Shellexecute offers a verb "properties" that is supposed to display the properties dialog of a file or folder.
When I call it from VB I always get an error SE_ERR_NOASSOC which means that there is no file associated with the given extension, which is plain wrong.
I tried it with all extensions I can think of.
Dim lResult as Long
lResult = ShellExecute(me.hwnd, "properties", "c:\winnt\system32\shell32.dll", vbNullString, vbNullString, 1)
MsgBox lResult
Any hints?
-
August 5th, 1999, 12:16 PM
#2
Re: ShellExecute and "properties" verb
It might be possible with the other version of ShellExecute , ShellExecuteEx.
Yuo need to pass it a record structure called SHELLEXECUTEINFO.I have some code in C so perhaps you can translate it for VB.In C :
void ShowFileProperties(LPCTSTR szPathName)
{
SHELLEXECUTEINFO sei;
ZeroMemory(&sei, sizeof(SHELLEXECUTEINFO));
sei.cbSize = sizeof(SHELLEXECUTEINFO);
sei.lpFile = szPathName //Name of File
sei.nShow = SW_SHOW //To show properties dialog
sei.fMask = SEE_MASK_INVOKEIDLIST;
sei.lpVerb = _TEXT("properties");
ShellExecuteEx(&sei);
}
Hope this helps
}
-
August 5th, 1999, 12:19 PM
#3
Re: ShellExecute and "properties" verb
Instead of passing the me.hwnd parameter for the handle it might work better if you Pass NULL or vbNull instead.
-
August 6th, 1999, 02:23 AM
#4
Re: ShellExecute and "properties" verb
Thank you very much!
It worked.
It's a shame that you posted your code as Anonymous.
I wanted to rate it as "excellent".
In case anyone else need the VB code.
It looks like this:
private Const SW_SHOW = 5
private Const SEE_MASK_INVOKEIDLIST = &HC
private Type SHELLEXECUTEINFO
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
' optional fields
lpIDList as Long
lpClass as string
hkeyClass as Long
dwHotKey as Long
hIcon as Long
hProcess as Long
End Type
private Declare Function ShellExecuteEx Lib "shell32.dll" (byref s as SHELLEXECUTEINFO) as Long
private Sub Command1_Click()
Dim s as SHELLEXECUTEINFO
s.cbSize = LenB(s)
s.lpFile = "c:\winnt\system32\shell32.dll"
s.nShow = SW_SHOW
s.fMask = SEE_MASK_INVOKEIDLIST
s.lpVerb = "properties"
ShellExecuteEx s
End Sub
-
August 6th, 1999, 03:18 AM
#5
Re: ShellExecute and "properties" verb
Well, I rated your post as excellent as it was in VB and I couldn't rate his !
Do you want this posted on the site ? - It's very useful - I'll change it so that you can pass any filename in if you wish.
Chris Eastwood
CodeGuru - the website for developers
http://www.codeguru.com/vb
-
August 6th, 1999, 03:20 AM
#6
Re: ShellExecute and "properties" verb
>Do you want this posted on the site ?
>I'll change it so that you can pass any filename in if you wish.
Go ahead!
-
May 10th, 2000, 09:07 AM
#7
Re: ShellExecute and "properties" verb
Hi,
Your code was very usefull.How do I get the properties for the current file.for eg, if the user clicks on File->properties, I want the properties Dialog box to be displayed for the current File and is there any way to automatically fill in the Title,comments in the properties Dialog box.
Please help.I am desperately looking for a solution.
Thank you
Priya
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
|