// NSIS Shell Folder Plugin // // Douglas Thrift // // $Id$ #include #include #include extern "C" void __declspec(dllexport) GetFolderPath(HWND parent, int string_size, char *variables, stack_t **stacktop, extra_parameters *extra) { EXDLL_INIT(); int folder(::popint_or()); unsigned long flags(::popint_or()); char path[MAX_PATH]; long code(::SHGetFolderPath(parent, folder, NULL, flags, path)); if (SUCCEEDED(code)) ::pushstring(path); else switch (code) { case S_FALSE: case E_FAIL: ::pushstring("Folder does not exist."); break; case E_INVALIDARG: ::pushstring("Invalid arguments."); break; default: ::pushstring("Unknown error."); } ::pushint(code); }