ยปCore Development>Code coverage>Tools/msi/msisupport.c

Python code coverage for Tools/msi/msisupport.c

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