Results 1 to 11 of 11

Thread: View Properties from shortcut

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2005
    Posts
    27

    View Properties from shortcut

    Hi,
    Is there any code with which I can view the properties of a file through his shortcut?

    Thanks.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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:
    1. Option Explicit
    2.  
    3. Private Type SHELLEXECUTEINFO
    4.     cbSize        As Long
    5.     fMask         As Long
    6.     hwnd          As Long
    7.     lpVerb        As String
    8.     lpFile        As String
    9.     lpParameters  As String
    10.     lpDirectory   As String
    11.     nShow         As Long
    12.     hInstApp      As Long
    13.     lpIDList      As Long     'Optional parameter
    14.     lpClass       As String   'Optional parameter
    15.     hkeyClass     As Long     'Optional parameter
    16.     dwHotKey      As Long     'Optional parameter
    17.     hIcon         As Long     'Optional parameter
    18.     hProcess      As Long     'Optional parameter
    19. End Type
    20.  
    21. Private Const SEE_MASK_INVOKEIDLIST = &HC
    22. Private Const SEE_MASK_NOCLOSEPROCESS = &H40
    23. Private Const SEE_MASK_FLAG_NO_UI = &H400
    24.  
    25. Private Declare Function ShellExecuteEx Lib "shell32.dll" (SEI As SHELLEXECUTEINFO) As Long
    26.  
    27. Private Sub ShowProperties(pstrFileName As String, plngOwnerhWnd As Long)
    28.  
    29.   'open a file properties property page for
    30.   'specified file if return value
    31.    Dim SEI As SHELLEXECUTEINFO
    32.   'Fill in the SHELLEXECUTEINFO structure
    33.    With SEI
    34.       .cbSize = Len(SEI)
    35.       .fMask = SEE_MASK_NOCLOSEPROCESS Or _
    36.                SEE_MASK_INVOKEIDLIST Or _
    37.                SEE_MASK_FLAG_NO_UI
    38.       .hwnd = plngOwnerhWnd
    39.       .lpVerb = "properties"
    40.       .lpFile = pstrFileName
    41.       .lpParameters = vbNullChar
    42.       .lpDirectory = vbNullChar
    43.       .nShow = 0
    44.       .hInstApp = 0
    45.       .lpIDList = 0
    46.    End With
    47.  
    48.   'call the API to display the property sheet
    49.    Call ShellExecuteEx(SEI)
    50.  
    51. End Sub
    52.  
    53. Private Sub Command1_Click()
    54. Call ShowProperties((Text1.Text), Me.hwnd)
    55. End Sub

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jun 2005
    Posts
    27

    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?

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: View Properties from shortcut

    You copied 'n pasted that code into the Declarations section of your form, correct?

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Jun 2005
    Posts
    27

    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.

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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?

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Jun 2005
    Posts
    27

    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.

  8. #8
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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?

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Jun 2005
    Posts
    27

    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.

  10. #10
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: View Properties from shortcut

    Quote 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!

  11. #11

    Thread Starter
    Junior Member
    Join Date
    Jun 2005
    Posts
    27

    Re: View Properties from shortcut

    Quote 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
  •  



Click Here to Expand Forum to Full Width