1 |
// NSIS Shell Folder Plugin |
2 |
// |
3 |
// Douglas Thrift |
4 |
// |
5 |
// $Id$ |
6 |
|
7 |
#include <Windows.h> |
8 |
#include <ShlObj.h> |
9 |
#include <nsis/pluginapi.h> |
10 |
|
11 |
extern "C" void __declspec(dllexport) GetFolderPath(HWND parent, int string_size, char *variables, stack_t **stacktop, extra_parameters *extra) |
12 |
{ |
13 |
EXDLL_INIT(); |
14 |
|
15 |
int folder(::popint_or()); |
16 |
unsigned long flags(::popint_or()); |
17 |
char path[MAX_PATH]; |
18 |
long code(::SHGetFolderPath(parent, folder, NULL, flags, path)); |
19 |
|
20 |
if (SUCCEEDED(code)) |
21 |
::pushstring(path); |
22 |
else |
23 |
switch (code) |
24 |
{ |
25 |
case S_FALSE: |
26 |
case E_FAIL: |
27 |
::pushstring("Folder does not exist."); |
28 |
break; |
29 |
case E_INVALIDARG: |
30 |
::pushstring("Invalid arguments."); |
31 |
break; |
32 |
default: |
33 |
::pushstring("Unknown error."); |
34 |
} |
35 |
|
36 |
::pushint(code); |
37 |
} |