|
-
Jun 21st, 2005, 08:48 AM
#1
Thread Starter
Junior Member
View Properties from shortcut
Hi,
Is there any code with which I can view the properties of a file through his shortcut?
Thanks.
-
Jun 21st, 2005, 09:02 AM
#2
Re: View Properties from shortcut
Welcome to the forums.
In this example, I use a textbox to contain the name of the file that I want the property page for. Instead of a filename, all you need to do is place the shortcut filename (which will be a .lnk file) there instead. (I just tested it, and it does work on a .lnk file - )
VB Code:
Option Explicit
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
lpIDList As Long 'Optional parameter
lpClass As String 'Optional parameter
hkeyClass As Long 'Optional parameter
dwHotKey As Long 'Optional parameter
hIcon As Long 'Optional parameter
hProcess As Long 'Optional parameter
End Type
Private Const SEE_MASK_INVOKEIDLIST = &HC
Private Const SEE_MASK_NOCLOSEPROCESS = &H40
Private Const SEE_MASK_FLAG_NO_UI = &H400
Private Declare Function ShellExecuteEx Lib "shell32.dll" (SEI As SHELLEXECUTEINFO) As Long
Private Sub ShowProperties(pstrFileName As String, plngOwnerhWnd As Long)
'open a file properties property page for
'specified file if return value
Dim SEI As SHELLEXECUTEINFO
'Fill in the SHELLEXECUTEINFO structure
With SEI
.cbSize = Len(SEI)
.fMask = SEE_MASK_NOCLOSEPROCESS Or _
SEE_MASK_INVOKEIDLIST Or _
SEE_MASK_FLAG_NO_UI
.hwnd = plngOwnerhWnd
.lpVerb = "properties"
.lpFile = pstrFileName
.lpParameters = vbNullChar
.lpDirectory = vbNullChar
.nShow = 0
.hInstApp = 0
.lpIDList = 0
End With
'call the API to display the property sheet
Call ShellExecuteEx(SEI)
End Sub
Private Sub Command1_Click()
Call ShowProperties((Text1.Text), Me.hwnd)
End Sub
-
Jun 21st, 2005, 09:32 AM
#3
Thread Starter
Junior Member
Re: View Properties from shortcut
Thanks a lot & good luck Pistons.
I'm sorry for the ignorance, but when I try to run these code I get the error : "Expected Identifier"
in the row: "Private Type SHELLEXECUTEINFO"
Do you have any clue where am I going wrong?
-
Jun 21st, 2005, 09:37 AM
#4
Re: View Properties from shortcut
You copied 'n pasted that code into the Declarations section of your form, correct?
-
Jun 21st, 2005, 09:45 AM
#5
Thread Starter
Junior Member
Re: View Properties from shortcut
No, I tried to copy the code to a text file and saved it as a .vbs
then, I used call ShowProperties with the path of the file as an argument.
-
Jun 21st, 2005, 09:54 AM
#6
Re: View Properties from shortcut
Hmmm...well I'm not sure how well, if at all, that would work with Windows Scripting. Are you trying to get the file properties from a web page?
-
Jun 21st, 2005, 09:57 AM
#7
Thread Starter
Junior Member
Re: View Properties from shortcut
No, my exact problem is I want to send by mail a shortcut to a flie, and I want the person getting the shortcut to be able to view \ edit the file's properties.
-
Jun 21st, 2005, 10:05 AM
#8
Re: View Properties from shortcut
There would have to be some form of container (like a VB form) within which to store and run the code to get the property page, so the person receiving the shortcut file would have to do something with it.
Are the people that will be receiving your file all within your company?
Is the file located on your local network?
-
Jun 21st, 2005, 10:10 AM
#9
Thread Starter
Junior Member
Re: View Properties from shortcut
The people recieving the file are recieving it through an outlook form, so maybe I could add the code to the form?
They are within my company and the file is located on the company's network.
-
Jun 21st, 2005, 10:16 AM
#10
Re: View Properties from shortcut
 Originally Posted by snir
The people recieving the file are recieving it through an outlook form, so maybe I could add the code to the form?
They are within my company and the file is located on the company's network.
Ok. That is very possible (although I do not have a lot of experience with using Outlook VBA).
I'd suggest you pop up to the VBA section, and create a new thread question asking how you would make this property page code work from an Outlook form.
If there is a way to do that, the VBA people there will know what it is.
Good luck!
-
Jun 21st, 2005, 10:43 AM
#11
Thread Starter
Junior Member
Re: View Properties from shortcut
 Originally Posted by Hack
Ok. That is very possible (although I do not have a lot of experience with using Outlook VBA).
I'd suggest you pop up to the VBA section, and create a new thread question asking how you would make this property page code work from an Outlook form.
If there is a way to do that, the VBA people there will know what it is.
Good luck! 
O.k. thanks a lot for your help
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
|