Displaying the File Properties Dialog


Author: Lothar A. Haensler

Displaying the File Properties Dialog

This code shows how to display the file properties dialog through VB5/6 Code.

screen shot

Paste the following code into a module in your project:


option Explicit
'
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

public Sub DisplayFileProperties(byval sFullFileAndPathName as string)
    Dim shInfo as SHELLEXECUTEINFO
    
    With shInfo
        .cbSize = LenB(shInfo)
        .lpFile = sFullFileAndPathName
        .nShow = SW_SHOW
        .fMask = SEE_MASK_INVOKEIDLIST
        .lpVerb = "properties"
    End With
    
    ShellExecuteEx shInfo
End Sub

Now simply call the DisplayFileProperties routine with the full file and path name of the required file to display the properties.

Download Zipped Project File (5k)



Comments

  • Extraordinaire

    Posted by jperciot on 07/15/2005 02:16am

    Ca marche mC*me en Visual C++ 6.0. Merci pour ce code, il m'a bien aidC).
    
    Voici le source C++ C_ intC)grer...
    (st = Chemin complet de votre fichier "c:\test.txt" par exemple)
    
    SHELLEXECUTEINFO ShExecInfo;
    		ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
    		ShExecInfo.lpVerb = "properties";
    		ShExecInfo.lpFile = st;
    		ShExecInfo.fMask = SEE_MASK_INVOKEIDLIST;
    		ShExecInfo.hwnd = NULL;
    		ShExecInfo.lpParameters = NULL;
    		ShExecInfo.lpDirectory = NULL;
    		ShExecInfo.nShow = SW_SHOW;
    		ShExecInfo.hInstApp = NULL;
    		ShellExecuteEx (&ShExecInfo);

    • Extra bis

      Posted by jperciot on 07/15/2005 04:37am

      ShExecInfo.lpVerb = "Properties"; sinon C'a plante.

      Reply
    Reply
  • reading width and height properties of digital media files?

    Posted by Legacy on 01/24/2003 12:00am

    Originally posted by: Giles

    is there any way of reading the width and height properties of digital media files with VB?

    .mov
    .avi
    .mpg

    ??

    Reply
  • Registry

    Posted by Legacy on 10/01/2002 12:00am

    Originally posted by: NetCreativeMind

    Proxy, Bandwidth, Registry, Database, C,
    VB, Website, Hardware, Network,
    Solutions.

    Reply
  • How to get just the revision number

    Posted by Legacy on 05/24/2002 12:00am

    Originally posted by: Richard Houde

    I want to ba able to just retrieve the revision number of a file. How would I go about getting that?
    
    Thanks.

    Reply
  • How to read file properties programmatically?

    Posted by Legacy on 04/02/2002 12:00am

    Originally posted by: Robert

    Great work! Do you know of a way to read this information programmatically?

    Reply
  • ShellExecuteEX

    Posted by Legacy on 01/09/2002 12:00am

    How can I detect whether the OK button or the Cancel button of the properties dialog has been clicked. The processID seems to be always equal to zero.

    Reply
  • Position

    Posted by Legacy on 12/08/2000 12:00am

    Originally posted by: Ingo

    How can I positioniering the file properity dialog??

    Reply
  • But for multiple files ??

    Posted by Legacy on 08/02/2000 12:00am

    Originally posted by: David Burg

    Ok, this is good, but what about a single dialog box for several files like in the windows explorer ? Because the lpName member of the structure is only designed for one file...

    Reply
  • Current active Filename

    Posted by Legacy on 05/10/2000 12:00am

    Originally posted by: Priya

    You have given the code for any file name.How do I do it for the current active Filename in my application.
    for eg. if the user selects file->properties in my appliaction, it should give the properties for the current active filename.

    please help
    Thank you
    Priya

    Reply
  • Displaying the File Properties Dialog

    Posted by Legacy on 10/19/1999 12:00am

    Originally posted by: Edwin Lima

    Excellent:

    It'sjust right what I was looking for

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Today's agile organizations pose operations teams with a tremendous challenge: to deploy new releases to production immediately after development and testing is completed. To ensure that applications are deployed successfully, an automatic and transparent process is required. We refer to this process as Zero Touch Deployment™. This white paper reviews two approaches to Zero Touch Deployment--a script-based solution and a release automation platform. The article discusses how each can solve the key …

  • On-demand Event Event Date: December 18, 2014 The Internet of Things (IoT) incorporates physical devices into business processes using predictive analytics. While it relies heavily on existing Internet technologies, it differs by including physical devices, specialized protocols, physical analytics, and a unique partner network. To capture the real business value of IoT, the industry must move beyond customized projects to general patterns and platforms. Check out this webcast and join industry experts as …

Most Popular Programming Stories

More for Developers

RSS Feeds