ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/NSISPlugins/ShellExecute/ShellExecute.cpp
(Generate patch)

Comparing NSISPlugins/ShellExecute/ShellExecute.cpp (file contents):
Revision 1161 by douglas, 2009-05-13T19:54:03-07:00 vs.
Revision 1167 by douglas, 2009-05-15T23:46:59-07:00

# Line 5 | Line 5
5   // $Id$
6  
7   #include <Windows.h>
8 < #include <pluginapi.h>
8 > #include <nsis/pluginapi.h>
9  
10 < extern "C" void __declspec(dllexport) Ex(HWND parent, int string_size, char *variables, stack_t **stacktop)
10 > #include <string>
11 >
12 > static char *popstring_alloc()
13 > {
14 >        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          EXDLL_INIT();
28  
29 <        // TODO: figure this out?
29 >        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   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines