CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    May 1999
    Posts
    3,332

    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?



  2. #2
    Guest

    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
    }



  3. #3
    Guest

    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.


  4. #4
    Join Date
    May 1999
    Posts
    3,332

    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






  5. #5
    Join Date
    May 1999
    Location
    Oxford UK
    Posts
    1,459

    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

  6. #6
    Join Date
    May 1999
    Posts
    3,332

    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!


  7. #7
    Join Date
    Mar 2000
    Location
    TX,USA
    Posts
    43

    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
  •  





Click Here to Expand Forum to Full Width

Featured