Hi,
Is there any code with which I can view the properties of a file through his shortcut?
Thanks.
Printable View
Hi,
Is there any code with which I can view the properties of a file through his shortcut?
Thanks.
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 - :thumb: )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
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?
You copied 'n pasted that code into the Declarations section of your form, correct?
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.
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?
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.
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?
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).Quote:
Originally Posted by snir
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! :thumb:
Quote:
Originally Posted by Hack
O.k. thanks a lot for your help :wave: