| 1 | n/a | #include "windows.h" |
|---|
| 2 | n/a | #include "msiquery.h" |
|---|
| 3 | n/a | |
|---|
| 4 | n/a | /* Print a debug message to the installer log file. |
|---|
| 5 | n/a | * To see the debug messages, install with |
|---|
| 6 | n/a | * msiexec /i pythonxy.msi /l*v python.log |
|---|
| 7 | n/a | */ |
|---|
| 8 | n/a | static UINT debug(MSIHANDLE hInstall, LPCSTR msg) |
|---|
| 9 | n/a | { |
|---|
| 10 | n/a | MSIHANDLE hRec = MsiCreateRecord(1); |
|---|
| 11 | n/a | if (!hRec || MsiRecordSetStringA(hRec, 1, msg) != ERROR_SUCCESS) { |
|---|
| 12 | n/a | return ERROR_INSTALL_FAILURE; |
|---|
| 13 | n/a | } |
|---|
| 14 | n/a | MsiProcessMessage(hInstall, INSTALLMESSAGE_INFO, hRec); |
|---|
| 15 | n/a | MsiCloseHandle(hRec); |
|---|
| 16 | n/a | return ERROR_SUCCESS; |
|---|
| 17 | n/a | } |
|---|
| 18 | n/a | |
|---|
| 19 | n/a | /* Check whether the TARGETDIR exists and is a directory. |
|---|
| 20 | n/a | * Set TargetExists appropriately. |
|---|
| 21 | n/a | */ |
|---|
| 22 | n/a | UINT __declspec(dllexport) __stdcall CheckDir(MSIHANDLE hInstall) |
|---|
| 23 | n/a | { |
|---|
| 24 | n/a | #define PSIZE 1024 |
|---|
| 25 | n/a | WCHAR wpath[PSIZE]; |
|---|
| 26 | n/a | char path[PSIZE]; |
|---|
| 27 | n/a | UINT result; |
|---|
| 28 | n/a | DWORD size = PSIZE; |
|---|
| 29 | n/a | DWORD attributes; |
|---|
| 30 | n/a | |
|---|
| 31 | n/a | |
|---|
| 32 | n/a | result = MsiGetPropertyW(hInstall, L"TARGETDIR", wpath, &size); |
|---|
| 33 | n/a | if (result != ERROR_SUCCESS) |
|---|
| 34 | n/a | return result; |
|---|
| 35 | n/a | wpath[size] = L'\0'; |
|---|
| 36 | n/a | path[size] = L'\0'; |
|---|
| 37 | n/a | |
|---|
| 38 | n/a | attributes = GetFileAttributesW(wpath); |
|---|
| 39 | n/a | if (attributes == INVALID_FILE_ATTRIBUTES || |
|---|
| 40 | n/a | !(attributes & FILE_ATTRIBUTE_DIRECTORY)) |
|---|
| 41 | n/a | { |
|---|
| 42 | n/a | return MsiSetPropertyA(hInstall, "TargetExists", "0"); |
|---|
| 43 | n/a | } else { |
|---|
| 44 | n/a | return MsiSetPropertyA(hInstall, "TargetExists", "1"); |
|---|
| 45 | n/a | } |
|---|
| 46 | n/a | } |
|---|
| 47 | n/a | |
|---|
| 48 | n/a | /* Update the state of the REGISTRY.tcl component according to the |
|---|
| 49 | n/a | * Extension and TclTk features. REGISTRY.tcl must be installed |
|---|
| 50 | n/a | * if both features are installed, and must be absent otherwise. |
|---|
| 51 | n/a | */ |
|---|
| 52 | n/a | UINT __declspec(dllexport) __stdcall UpdateEditIDLE(MSIHANDLE hInstall) |
|---|
| 53 | n/a | { |
|---|
| 54 | n/a | INSTALLSTATE ext_old, ext_new, tcl_old, tcl_new, reg_new; |
|---|
| 55 | n/a | UINT result; |
|---|
| 56 | n/a | |
|---|
| 57 | n/a | result = MsiGetFeatureStateA(hInstall, "Extensions", &ext_old, &ext_new); |
|---|
| 58 | n/a | if (result != ERROR_SUCCESS) |
|---|
| 59 | n/a | return result; |
|---|
| 60 | n/a | result = MsiGetFeatureStateA(hInstall, "TclTk", &tcl_old, &tcl_new); |
|---|
| 61 | n/a | if (result != ERROR_SUCCESS) |
|---|
| 62 | n/a | return result; |
|---|
| 63 | n/a | |
|---|
| 64 | n/a | /* If the current state is Absent, and the user did not select |
|---|
| 65 | n/a | the feature in the UI, Installer apparently sets the "selected" |
|---|
| 66 | n/a | state to unknown. Update it to the current value, then. */ |
|---|
| 67 | n/a | if (ext_new == INSTALLSTATE_UNKNOWN) |
|---|
| 68 | n/a | ext_new = ext_old; |
|---|
| 69 | n/a | if (tcl_new == INSTALLSTATE_UNKNOWN) |
|---|
| 70 | n/a | tcl_new = tcl_old; |
|---|
| 71 | n/a | |
|---|
| 72 | n/a | // XXX consider current state of REGISTRY.tcl? |
|---|
| 73 | n/a | if (((tcl_new == INSTALLSTATE_LOCAL) || |
|---|
| 74 | n/a | (tcl_new == INSTALLSTATE_SOURCE) || |
|---|
| 75 | n/a | (tcl_new == INSTALLSTATE_DEFAULT)) && |
|---|
| 76 | n/a | ((ext_new == INSTALLSTATE_LOCAL) || |
|---|
| 77 | n/a | (ext_new == INSTALLSTATE_SOURCE) || |
|---|
| 78 | n/a | (ext_new == INSTALLSTATE_DEFAULT))) { |
|---|
| 79 | n/a | reg_new = INSTALLSTATE_SOURCE; |
|---|
| 80 | n/a | } else { |
|---|
| 81 | n/a | reg_new = INSTALLSTATE_ABSENT; |
|---|
| 82 | n/a | } |
|---|
| 83 | n/a | result = MsiSetComponentStateA(hInstall, "REGISTRY.tcl", reg_new); |
|---|
| 84 | n/a | return result; |
|---|
| 85 | n/a | } |
|---|
| 86 | n/a | |
|---|
| 87 | n/a | BOOL APIENTRY DllMain(HANDLE hModule, |
|---|
| 88 | n/a | DWORD ul_reason_for_call, |
|---|
| 89 | n/a | LPVOID lpReserved) |
|---|
| 90 | n/a | { |
|---|
| 91 | n/a | return TRUE; |
|---|
| 92 | n/a | } |
|---|
| 93 | n/a | |
|---|