Delphi Win API function [ShellAPI] ShellExecute function

Precedents: uses ShellAPI;

函数原型:function ShellExecute(hWnd: HWND; Operation, FileName, Parameters,Directory: PChar; ShowCmd: Integer): HINST; stdcall; 

  hWnd : used to specify the parent window handle. When an error occurs during a function call, it will serve as the parent window Windows message window. For example, it may be set to the main application window handle, i.e. Application.Handle, may be provided (the function obtained by GetDesktopWindow) desktop window handle. 
  Operation : specifies the operation to be performed. When to nil, it represents the default implementation of "open". 
    open: performing the specified operation represented by the parameter FileName program, or open the specified by FileName parameter files or folders;
    print: print operation indicates the file specified by the parameter FileName;
    explore: operation represents browse specified by the FileName parameter folder.
    
  FileName : used to specify the name of the file to open the program to execute the file name or folder name you want to browse. 
  The Parameters : If the FileName parameter is an executable program, this parameter specifies the command-line parameters, otherwise this parameter should be nil or PChar (0). 
  Directory : used to specify the default directory. 
  ShowCmd : If the parameter FileName is an executable program, the initial This parameter specifies the window display mode, otherwise this parameter should be set to 0. 
    SW_HIDE Hide 
    SW_MAXIMIZE maximize 
    SW_MINIMIZE minimized, and the Z order after the order of the window (i.e., the window layer) of the window is active 
    SW_RESTORE activation and reduced window size is initialized to the current size and status SW_SHOW active window 
    SW_SHOW display a window with the current size and position, so that it enters the active state while 
    SW_SHOWDEFAULT run in default mode
    SW_SHOWMAXIMIZED and maximize the active window 
    SW_SHOWMINIMIZED minimize the active window and 
    SW_SHOWMINNOACTIVE minimized but does not change the currently active window 
    SW_SHOWNA displayed in the window but does not change the current state of the currently active window 
    SW_SHOWNOACTIVATE to initialize the size of the display window but does not change the currently active window 
    SW_SHOWNORMAL activate and display window, if it is the largest (small) technology, the window will be restored. This value should be used when you first run the program 
  Function succeeds, the instance is executing the program is returned. If the return value is less than 32, then an error occurred. 
 
E.g:
  Open Calculator: ShellExecute (Handle 'open', 'calc.exe', NULL, NULL, SW_SHOWMAXIMIZED);
  Open URL: ShellExecute (Handle, 'open', PChar ( 'http://www.baidu.com'), nil, nil, SW_SHOW);
  Open specified directory: ShellExecute (Handle, 'explore', PChar ( 'c: / windows)', nil, nil, SW_SHOW);
  Mail message window opens: ShellExecute (handle, 'open', '***@163.com', nil, nil, SW_SHOWNORMAL);
 
Updated: 2019.12.24
From: https: //www.cnblogs.com/guorongtao/p/12089515.html

Guess you like

Origin www.cnblogs.com/guorongtao/p/12089515.html