[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Opening the "My Computer" in Win32

Posted on 1997-07-16
Medium Priority
Last Modified: 2010-04-06
How can I open the "My Computer" on the Desktop within my Delphi 3 (perhaps 2 is the same) program ?
Question by:webers
  • 2
  • 2

Accepted Solution

pcs071997 earned 50 total points
ID: 1338972
You can use this function(win32 shell API)You can use that you want to using ICON or CLASS NAME or etc. MY COMPUTER' CLASS NAME => CabinetWClassShellExecuteEx(LPSHELLEXECUTEINFO lpExecInfo);
typedef struct _SHELLEXECUTEINFO {   // sei
    DWORD     cbSize;
    ULONG     fMask;
    HWND      hwnd;
    LPCSTR    lpVerb;
    LPCSTR    lpFile;
    LPCSTR    lpParameters;
    LPCSTR    lpDirectory;
    int       nShow;
    HINSTANCE hInstApp;
    // Optional members
    LPVOID lpIDList;
    LPCSTR lpClass;
    HKEY   hkeyClass;
    DWORD  dwHotKey;
    HANDLE hIcon;
    HANDLE hProcess;

Specifies the size, in bytes, of the structure.
This is an array of flags that indicate the content and validity of the other structure members. You can specify a combination of the following values:Value Meaning
Use the class key given by the hkeyClass member.
Use the class name given by the lpClass member.
The lpFile member is a Universal Naming Convention (UNC) path of a file on a network. Validate the share and connect to a drive letter.
Expand any environment variables specified in the string given by the lpDirectory or lpFile member.
Wait for the DDE conversation to terminate before returning, if the ShellExecuteEx function causes a DDE conversation to start.
Do not display an error message box if an error occurs.
Use the hot key given by the dwHotKey member.
Use the icon given by the hIcon member.
Use the item identifier list given by the lpIDList member.
Use the item identifier list given by the lpIDList member to invoke an application. If this member is NULL, the function creates an item identifier list and invokes the application. SEE_MASK_INVOKEIDLIST overrides SEE_MASK_IDLIST.
Leave the process running after the ShellExecuteEx function exits. The hProcess member receives the handle of the process.

Handle to the parent window for any message boxes that the system may produce while executing this function (for example, for error reporting).
Pointer to a string specifying the name of a verb. The verb specifies an action for the application to perform. This member defaults to ¡°Open¡± if no verb is specified.
Pointer to a list of null-terminated strings that specify the names of the files to open or print. The function can open an executable file or a document file. The function can print a document file. If the path is not included with a name, the current directory is assumed.
Pointer to a null-terminated string containing the application parameters. The parameters must be separated by spaces. To include double quotation marks, you must enclose the marks in double quotation marks, as in the following example:

sei.lpParameters = "An example: \"\"\"quoted text\"\"\"";
In this case, the application receives three parameters: An, example:, and ¡°quoted text¡±.
If lpFile specifies a document file, lpParameters should be NULL.
Pointer to a null-terminated string that specifies the name of the working directory. If this member is not specified, the current directory is used as the working directory.
Show flags. Can be one of the SW_ values described for the ShowWindow function. If lpFile specifies an executable file, nShow specifies how the application is to be shown when it is opened. If lpFile specifies a document file, nShow should be zero.
Handle to the instance of the application that was started or an error value if the application could not be started. (This handle could also be the handle of a dynamic data exchange [DDE] server application.) This member is set on return. Error values can be one of the following:Value
File not found
Path not found
Access denied
Out of memory
Dynamic-link library not found
Cannot share open file
File association information not complete
DDE operation timed out
DDE operation failed
DDE operation busy
File association not available

Pointer to an ITEMIDLIST structure that contains an item identifier list that uniquely identifies the file to execute. Ignored if fMask is not set to SEE_MASK_IDLIST.
Pointer to a null-terminated string specifying the name of a file class or a globally unique identifier (GUID). Ignored if fMask is not set to SEE_MASK_CLASSNAME.
Handle to the registry key for the file class. Ignored if fMask is not set to SEE_MASK_CLASSKEY.
Hot key to associate with the application. The low-order word is the virtual-key code, and the high-order word is a modifier flag (HOTKEYF_). For a list of modifier flags, see the description of the WM_SETHOTKEY message. Ignored if fMask is not set to SEE_MASK_HOTKEY.
Handle to the icon for the file class. Ignored if fMask is not set to SEE_MASK_ICON.
Handle to the newly started application. This member is set on return and is always NULL if fMask is not set to SEE_MASK_NOCLOSEPROCESS.


Expert Comment

ID: 1338973
Another Win32 API to look into is SHGetSpecialFolderLocation (this is probably the correct way to do it, instead of using a hard-coded value for the folder name).

    HWND  hwndOwner,       
    int  nFolder,       
    LPITEMIDLIST  * ppidl      

The value you want to use for nFolder is CSIDL_DRIVES.


Expert Comment

ID: 1338974
I thought that webers wanted to run the "my computer" folder.Aren't you ?

Expert Comment

ID: 1338975
Yes, that's what he wants. My comment is regarding getting the folder name for "My Computer", instead of hard-coding the class name into your program.

Author Comment

ID: 1338976
Sorry, but I don't know, if that's the answer for my question.  I just wanted to execute the "My Computer" on the desktop.  The same as if you dobleclick on the "My Computer" should happen then.  Did you answer that ?? I'm not very well in API programming. Perhaps you could send me an example ??

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Screencast - Getting to Know the Pipeline
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month18 days, 23 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question