Programmatically open a Windows Folder

This is a discussion on Programmatically open a Windows Folder within the Windows Programming forums, part of the Platform Specific Boards category; Hi I am looking for a way to open a windows folder from within my programme as if it had ...

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    8

    Question Programmatically open a Windows Folder

    Hi
    I am looking for a way to open a windows folder from within my programme as if it had been opened from within 'MyComputer'
    I guess it is an API command but have looked in all my documentation and found nothing. I am programming in Borland C++ for Windows 95/98 OS. Any help would very appreciated.

    Shaman

  2. #2
    larry
    Guest
    I found this in my Windows API documentation. I never used this function, so I don't know whether it works. Maybe it's obselete, for win16 or something. Try it. Here is the description I found:
    ------------------------------------------------------
    #include ver.h

    UINT GetWindowsDir(lpszAppDir, lpszPath, cbPath)

    LPCSTR lpszAppDir; /* address of Windows directory */
    LPSTR lpszPath; /* address of buffer for path */
    int cbPath; /* size of buffer for path */


    The GetWindowsDir function retrieves the path of the Windows directory. This directory contains such files as Windows applications, initialization files, and help files.
    GetWindowsDir is used by MS-DOS applications that set up Windows applications; it exists only in the static-link version of the File Installation library. Windows applications should use the GetWindowsDirectory function to determine the Windows directory.

    Parameter Description

    lpszAppDir Specifies the current directory in a search for Windows files. If the Windows directory is not on the path, the application must prompt the user for its location and pass that string to the GetWindowsDir function in the lpszAppDir parameter.
    lpszPath Points to the buffer that will receive the null-terminated string containing the path.
    cbPath Specifies the size, in bytes, of the buffer pointed to by the lpszPath parameter.

    Returns

    The return value is the length of the string copied to the lpszPath parameter, including the terminating null character, if the function is successful. If the return value is greater than the cbPath parameter, it is the size of the buffer required to hold the path. The return value is zero if the function fails.

    Comments

    The path that this function retrieves does not end with a backslash unless the Windows directory is the root directory. For example, if the Windows directory is named WINDOWS on drive C, the path retrieved by this function is C:\WINDOWS. If Windows is installed in the root directory of drive C, the path retrieved is C:\.

    After the GetWindowsDir function locates the Windows directory, it caches the location for use by subsequent calls to the function.
    ----------------------------------------------------------------

  3. #3
    larry
    Guest
    Oh... Sorry, I see you asked for something else. Well, what about calling an explorer.exe application from the directory you get as a result of getWindowsDir function? Just run it as "windowsdirectory\explorer.exe windowsdirectory" It creates an explorer.exe window with this directory opened (without the tree, exactly as if it would from My Computer icon (if you use w98)).

  4. #4
    zen
    zen is offline
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    You could use ShellExecute(). This would open c:\Temp -

    ShellExecute(hWnd,"open",NULL,NULL,"C:\\Temp",SW_S HOWNORMAL);

    If you need an explorer type view you can change the "open" to "explore".
    zen

  5. #5
    Registered User
    Join Date
    Sep 2001
    Posts
    8

    Thumbs up Thanx Guys

    Thanx for your help, never even thought of using ShellExecute

    Shaman

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Who doesn't format Windows?
    By C_ntua in forum Tech Board
    Replies: 89
    Last Post: 11-11-2008, 11:29 AM
  2. Codec Bitrates?
    By gvector1 in forum C# Programming
    Replies: 2
    Last Post: 06-16-2003, 08:39 AM
  3. FlashWindowEx not declared?
    By Aidman in forum Windows Programming
    Replies: 3
    Last Post: 05-17-2003, 02:58 AM
  4. Problems with open and save boxes
    By pinkcheese in forum Windows Programming
    Replies: 3
    Last Post: 05-21-2002, 06:03 PM
  5. open folder
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 05-10-2002, 12:36 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21