ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/NSISPlugins/ShellExecute/ShellExecute.cpp
Revision: 1167
Committed: 2009-05-15T23:46:59-07:00 (16 years, 1 month ago) by douglas
File size: 1441 byte(s)
Log Message:
I think this should work...

File Contents

# User Rev Content
1 douglas 1161 // NSIS Shell Execute Plugin
2     //
3     // Douglas Thrift
4     //
5     // $Id$
6    
7     #include <Windows.h>
8 douglas 1167 #include <nsis/pluginapi.h>
9 douglas 1161
10 douglas 1167 #include <string>
11    
12     static char *popstring_alloc()
13 douglas 1161 {
14 douglas 1167 char *string = new char[::g_stringsize];
15    
16     if (::popstringn(string, 0) || string == std::string("0", 1) || string == std::string("NULL", 4))
17     {
18     delete [] string;
19     return NULL;
20     }
21    
22     return string;
23     }
24    
25     extern "C" void __declspec(dllexport) Ex(HWND parent, int string_size, char *variables, stack_t **stacktop, extra_parameters *extra)
26     {
27 douglas 1161 EXDLL_INIT();
28    
29 douglas 1167 SHELLEXECUTEINFO info;
30    
31     info.cbSize = sizeof (info);
32     info.fMask = ::popint_or();
33     info.hwnd = parent;
34     info.lpVerb = ::popstring_alloc();
35     info.lpFile = ::popstring_alloc();
36     info.lpParameters = ::popstring_alloc();
37     info.nShow = ::popint();
38     info.lpIDList = NULL;
39    
40     if (info.fMask & SEE_MASK_CLASSNAME)
41     info.lpClass = ::popstring_alloc();
42    
43     info.hkeyClass = NULL;
44     info.dwHotKey = 0;
45     info.hMonitor = NULL;
46    
47     int code;
48    
49     if (code = ::ShellExecuteEx(&info))
50     ::pushint(reinterpret_cast<int>(info.hProcess));
51     else
52     {
53     char *message;
54    
55     ::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, ::GetLastError(), 0, reinterpret_cast<char *>(&message), sizeof (message), NULL);
56     ::pushstring(message);
57     ::LocalFree(message);
58     }
59    
60     ::pushint(code);
61    
62     delete [] info.lpVerb, delete [] info.lpFile;
63     delete [] info.lpParameters;
64 douglas 1161 }

Properties

Name Value
svn:keywords Id