Changeset 3624 for trunk/src/shell32/shellord.cpp
- Timestamp:
- May 28, 2000, 6:42:54 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/shell32/shellord.cpp
r3271 r3624 1 /* $Id: shellord.cpp,v 1. 7 2000-03-29 15:24:05 cbratschiExp $ */1 /* $Id: shellord.cpp,v 1.8 2000-05-28 16:42:54 sandervl Exp $ */ 2 2 /* 3 3 * The parameters of many functions changes between different OS versions … … 763 763 } 764 764 /************************************************************************* 765 * ShellExecuteExA [SHELL32.292] 766 * 767 */ 765 * ShellExecuteExA [SHELL32.292] 766 * 767 * placeholder in the commandline: 768 * %1 file 769 * %2 printer 770 * %3 driver 771 * %4 port 772 * %I adress of a global item ID (explorer switch /idlist) 773 * %L ??? path/url/current file ??? 774 * %S ??? 775 * %* all following parameters (see batfile) 776 */ 777 #include "process.h" /* we can get rid of it hopefully */ 778 #include "task.h" 768 779 BOOL WINAPI ShellExecuteExA (LPSHELLEXECUTEINFOA sei) 769 { CHAR szApplicationName[MAX_PATH],szCommandline[MAX_PATH],szPidl[20]; 770 LPSTR pos; 771 int gap, len; 772 STARTUPINFOA startupinfo; 773 PROCESS_INFORMATION processinformation; 774 775 WARN("mask=0x%08lx hwnd=0x%04x verb=%s file=%s parm=%s dir=%s show=0x%08x class=%s incomplete\n", 776 sei->fMask, sei->hwnd, sei->lpVerb, sei->lpFile, 777 sei->lpParameters, sei->lpDirectory, sei->nShow, 778 (sei->fMask & SEE_MASK_CLASSNAME) ? sei->lpClass : "not used"); 779 780 ZeroMemory(szApplicationName,MAX_PATH); 780 { CHAR szApplicationName[MAX_PATH],szCommandline[MAX_PATH],szPidl[20]; 781 LPSTR pos; 782 int gap, len; 783 STARTUPINFOA startup; 784 PROCESS_INFORMATION info; 785 786 WARN("mask=0x%08lx hwnd=0x%04x verb=%s file=%s parm=%s dir=%s show=0x%08x class=%s incomplete\n", 787 sei->fMask, sei->hwnd, sei->lpVerb, sei->lpFile, 788 sei->lpParameters, sei->lpDirectory, sei->nShow, 789 (sei->fMask & SEE_MASK_CLASSNAME) ? sei->lpClass : "not used"); 790 791 ZeroMemory(szApplicationName,MAX_PATH); 792 if (sei->lpFile) 793 strcpy(szApplicationName, sei->lpFile); 794 795 ZeroMemory(szCommandline,MAX_PATH); 796 if (sei->lpParameters) 797 strcpy(szCommandline, sei->lpParameters); 798 799 if (sei->fMask & (SEE_MASK_CLASSKEY | SEE_MASK_INVOKEIDLIST | SEE_MASK_ICON | SEE_MASK_HOTKEY | 800 SEE_MASK_CONNECTNETDRV | SEE_MASK_FLAG_DDEWAIT | 801 SEE_MASK_DOENVSUBST | SEE_MASK_FLAG_NO_UI | SEE_MASK_UNICODE | 802 SEE_MASK_NO_CONSOLE | SEE_MASK_ASYNCOK | SEE_MASK_HMONITOR )) 803 { 804 FIXME("flags ignored: 0x%08lx\n", sei->fMask); 805 } 806 807 /* launch a document by fileclass like 'Wordpad.Document.1' */ 808 if (sei->fMask & SEE_MASK_CLASSNAME) 809 { 810 /* the commandline contains 'c:\Path\wordpad.exe "%1"' */ 811 HCR_GetExecuteCommand(sei->lpClass, (sei->lpVerb) ? sei->lpVerb : "open", szCommandline, 256); 812 /* fixme: get the extension of lpFile, check if it fits to the lpClass */ 813 TRACE("SEE_MASK_CLASSNAME->'%s'\n", szCommandline); 814 } 815 816 /* process the IDList */ 817 if ( (sei->fMask & SEE_MASK_INVOKEIDLIST) == SEE_MASK_INVOKEIDLIST) /*0x0c*/ 818 { 819 SHGetPathFromIDListA ((LPCITEMIDLIST)sei->lpIDList,szApplicationName); 820 TRACE("-- idlist=%p (%s)\n", sei->lpIDList, szApplicationName); 821 } 822 else 823 { 824 if (sei->fMask & SEE_MASK_IDLIST ) 825 { 826 pos = strstr(szCommandline, "%I"); 827 if (pos) 828 { 829 LPVOID pv; 830 HGLOBAL hmem = SHAllocShared ( (LPITEMIDLIST)sei->lpIDList, ILGetSize((LPITEMIDLIST)sei->lpIDList), 0); 831 pv = SHLockShared(hmem,0); 832 sprintf(szPidl,":%p",pv ); 833 SHUnlockShared((HANDLE)pv); 834 835 gap = strlen(szPidl); 836 len = strlen(pos)-2; 837 memmove(pos+gap,pos+2,len); 838 memcpy(pos,szPidl,gap); 839 840 } 841 } 842 } 843 844 TRACE("execute:'%s','%s'\n",szApplicationName, szCommandline); 845 846 strcat(szApplicationName, " "); 847 strcat(szApplicationName, szCommandline); 848 849 ZeroMemory(&startup,sizeof(STARTUPINFOA)); 850 startup.cb = sizeof(STARTUPINFOA); 851 852 if (! CreateProcessA(NULL, szApplicationName, 853 NULL, NULL, FALSE, 0, 854 NULL, NULL, &startup, &info)) 855 { 856 sei->hInstApp = GetLastError(); 857 return FALSE; 858 } 859 860 sei->hInstApp = 33; 861 862 /* Give 30 seconds to the app to come up */ 863 if ( WaitForInputIdle ( info.hProcess, 30000 ) == 0xFFFFFFFF ) 864 ERR("WaitForInputIdle failed: Error %ld\n", GetLastError() ); 865 866 if(sei->fMask & SEE_MASK_NOCLOSEPROCESS) 867 sei->hProcess = info.hProcess; 868 else 869 CloseHandle( info.hProcess ); 870 CloseHandle( info.hThread ); 871 return TRUE; 872 } 873 874 /************************************************************************* 875 * ShellExecuteExW [SHELL32.293] 876 * 877 */ 878 BOOL WINAPI ShellExecuteExW (LPSHELLEXECUTEINFOW sei) 879 { SHELLEXECUTEINFOA seiA; 880 DWORD ret; 881 882 TRACE("%p\n", sei); 883 884 memcpy(&seiA, sei, sizeof(SHELLEXECUTEINFOA)); 885 886 if (sei->lpVerb) 887 seiA.lpVerb = HEAP_strdupWtoA( GetProcessHeap(), 0, sei->lpVerb); 888 781 889 if (sei->lpFile) 782 strcpy(szApplicationName, sei->lpFile); 783 784 ZeroMemory(szCommandline,MAX_PATH); 890 seiA.lpFile = HEAP_strdupWtoA( GetProcessHeap(), 0, sei->lpFile); 891 785 892 if (sei->lpParameters) 786 strcpy(szCommandline, sei->lpParameters); 787 788 if (sei->fMask & (SEE_MASK_CLASSKEY | SEE_MASK_INVOKEIDLIST | SEE_MASK_ICON | SEE_MASK_HOTKEY | 789 SEE_MASK_NOCLOSEPROCESS | SEE_MASK_CONNECTNETDRV | SEE_MASK_FLAG_DDEWAIT | 790 SEE_MASK_DOENVSUBST | SEE_MASK_FLAG_NO_UI | SEE_MASK_UNICODE | 791 SEE_MASK_NO_CONSOLE | SEE_MASK_ASYNCOK | SEE_MASK_HMONITOR )) 792 { FIXME("flags ignored: 0x%08lx\n", sei->fMask); 793 } 794 795 if (sei->fMask & SEE_MASK_CLASSNAME) 796 { HCR_GetExecuteCommand(sei->lpClass, (sei->lpVerb) ? sei->lpVerb : "open", szCommandline, 256); 797 } 798 799 /* process the IDList */ 800 if ( (sei->fMask & SEE_MASK_INVOKEIDLIST) == SEE_MASK_INVOKEIDLIST) /*0x0c*/ 801 { SHGetPathFromIDListA ((LPCITEMIDLIST)sei->lpIDList,szApplicationName); 802 TRACE("-- idlist=%p (%s)\n", sei->lpIDList, szApplicationName); 803 } 804 else 805 { if (sei->fMask & SEE_MASK_IDLIST ) 806 { /* %I is the adress of a global item ID*/ 807 pos = strstr(szCommandline, "%I"); 808 if (pos) 809 { HGLOBAL hmem = SHAllocShared ( sei->lpIDList, ILGetSize((LPCITEMIDLIST)sei->lpIDList), 0); 810 sprintf(szPidl,":%li",(DWORD)SHLockShared(hmem,0) ); 811 SHUnlockShared(hmem); 812 813 gap = strlen(szPidl); 814 len = strlen(pos)-2; 815 memmove(pos+gap,pos+2,len); 816 memcpy(pos,szPidl,gap); 817 818 } 819 } 820 } 821 822 pos = strstr(szCommandline, ",%L"); /* dunno what it means: kill it*/ 823 if (pos) 824 { len = strlen(pos)-2; 825 *pos=0x0; 826 memmove(pos,pos+3,len); 827 } 828 829 TRACE("execute: %s %s\n",szApplicationName, szCommandline); 830 831 ZeroMemory(&startupinfo,sizeof(STARTUPINFOA)); 832 startupinfo.cb = sizeof(STARTUPINFOA); 833 834 return CreateProcessA(szApplicationName[0] ? szApplicationName:NULL, 835 szCommandline[0] ? szCommandline : NULL, 836 NULL, NULL, FALSE, 0, 837 NULL, NULL, &startupinfo, &processinformation); 838 839 840 } 841 /************************************************************************* 842 * ShellExecuteExW [SHELL32.293] 843 * 844 */ 845 BOOL WINAPI ShellExecuteExW (LPSHELLEXECUTEINFOW sei) 846 { SHELLEXECUTEINFOA seiA; 847 DWORD ret; 848 849 TRACE("%p\n", sei); 850 851 memcpy(&seiA, sei, sizeof(SHELLEXECUTEINFOA)); 852 853 if (sei->lpVerb) 854 seiA.lpVerb = HEAP_strdupWtoA( GetProcessHeap(), 0, sei->lpVerb); 855 856 if (sei->lpFile) 857 seiA.lpFile = HEAP_strdupWtoA( GetProcessHeap(), 0, sei->lpFile); 858 859 if (sei->lpParameters) 860 seiA.lpParameters = HEAP_strdupWtoA( GetProcessHeap(), 0, sei->lpParameters); 861 862 if (sei->lpDirectory) 863 seiA.lpDirectory = HEAP_strdupWtoA( GetProcessHeap(), 0, sei->lpDirectory); 893 seiA.lpParameters = HEAP_strdupWtoA( GetProcessHeap(), 0, sei->lpParameters); 894 895 if (sei->lpDirectory) 896 seiA.lpDirectory = HEAP_strdupWtoA( GetProcessHeap(), 0, sei->lpDirectory); 864 897 865 898 if ((sei->fMask & SEE_MASK_CLASSNAME) && sei->lpClass) 866 867 868 869 870 871 872 if (seiA.lpVerb) 873 if (seiA.lpFile)HeapFree( GetProcessHeap(), 0, (LPSTR) seiA.lpFile );874 if (seiA.lpParameters)HeapFree( GetProcessHeap(), 0, (LPSTR) seiA.lpParameters );875 if (seiA.lpDirectory)HeapFree( GetProcessHeap(), 0, (LPSTR) seiA.lpDirectory );876 if (seiA.lpClass)HeapFree( GetProcessHeap(), 0, (LPSTR) seiA.lpClass );877 878 899 seiA.lpClass = HEAP_strdupWtoA( GetProcessHeap(), 0, sei->lpClass); 900 else 901 seiA.lpClass = NULL; 902 903 ret = ShellExecuteExA(&seiA); 904 905 if (seiA.lpVerb) HeapFree( GetProcessHeap(), 0, (LPSTR) seiA.lpVerb ); 906 if (seiA.lpFile) HeapFree( GetProcessHeap(), 0, (LPSTR) seiA.lpFile ); 907 if (seiA.lpParameters) HeapFree( GetProcessHeap(), 0, (LPSTR) seiA.lpParameters ); 908 if (seiA.lpDirectory) HeapFree( GetProcessHeap(), 0, (LPSTR) seiA.lpDirectory ); 909 if (seiA.lpClass) HeapFree( GetProcessHeap(), 0, (LPSTR) seiA.lpClass ); 910 911 return ret; 879 912 } 880 913
Note:
See TracChangeset
for help on using the changeset viewer.