1 #define WIN32_NO_STATUS
2 #define WIN32_LEAN_AND_MEAN
8 #define NT_PARAMS L"NT3.51 Intel Params"
9 #define MSSETUP_PATH L"~MSSETUP.T\\"
11 static UINT WINAPI
ExtCabCallback(PVOID Context
, UINT Notification
, UINT_PTR Param1
, UINT_PTR Param2
)
13 FILE_IN_CABINET_INFO_W
*pInfo
;
14 FILEPATHS_W
*pFilePaths
;
18 case SPFILENOTIFY_FILEINCABINET
:
19 pInfo
= (FILE_IN_CABINET_INFO_W
*)Param1
;
20 wcscpy(pInfo
->FullTargetName
, (LPCWSTR
)Context
);
21 wcscat(pInfo
->FullTargetName
, pInfo
->NameInCabinet
);
23 case SPFILENOTIFY_FILEEXTRACTED
:
24 pFilePaths
= (FILEPATHS_W
*)Param1
;
30 BOOL
DeleteDirectory(LPWSTR lpszDir
)
32 SHFILEOPSTRUCT fileop
;
33 DWORD len
= wcslen(lpszDir
);
34 WCHAR
*pszFrom
= HeapAlloc(GetProcessHeap(), 0, (len
+ 2) * sizeof(WCHAR
));
37 wcscpy(pszFrom
, lpszDir
);
42 fileop
.wFunc
= FO_DELETE
;
43 fileop
.pFrom
= pszFrom
;
45 fileop
.fFlags
= FOF_NOCONFIRMATION
|FOF_SILENT
;
46 fileop
.fAnyOperationsAborted
= FALSE
;
47 fileop
.lpszProgressTitle
= NULL
;
48 fileop
.hNameMappings
= NULL
;
50 ret
= SHFileOperation(&fileop
);
51 HeapFree(GetProcessHeap(), 0, &pszFrom
);
55 VOID
GetSystemDrive(LPWSTR lpszDrive
)
57 WCHAR szWindir
[MAX_PATH
];
58 GetWindowsDirectoryW(szWindir
, MAX_PATH
);
59 _wsplitpath(szWindir
, lpszDrive
, NULL
, NULL
, NULL
);
60 wcscat(lpszDrive
, L
"\\");
63 int APIENTRY
wWinMain(HINSTANCE hInstance
,
64 HINSTANCE hPrevInstance
,
68 WCHAR szSetupPath
[MAX_PATH
];
69 WCHAR szFileName
[MAX_PATH
];
70 WCHAR szCabFileName
[MAX_PATH
];
71 WCHAR szCabFilePath
[MAX_PATH
];
72 WCHAR szTempDirName
[50];
73 WCHAR szCmdLine
[MAX_PATH
];
74 WCHAR szTempCmdLine
[MAX_PATH
];
75 WCHAR szTempPath
[MAX_PATH
];
76 WCHAR szFullTempPath
[MAX_PATH
];
79 PROCESS_INFORMATION processInfo
;
80 STARTUPINFO startupInfo
;
81 UNREFERENCED_PARAMETER(hPrevInstance
);
82 UNREFERENCED_PARAMETER(nCmdShow
);
84 GetCurrentDirectory(MAX_PATH
, szSetupPath
);
85 wcscat(szSetupPath
, L
"\\");
86 wcscpy(szFileName
, szSetupPath
);
87 wcscat(szFileName
, L
"setup.lst");
89 if (GetFileAttributes(szFileName
) == INVALID_FILE_ATTRIBUTES
)
91 MessageBoxW(0, L
"Cannot find Setup.lst file", L
"Error", MB_OK
| MB_ICONERROR
);
95 /* read information from setup.lst */
96 GetPrivateProfileStringW(NT_PARAMS
, L
"CabinetFile", NULL
, szCabFileName
, MAX_PATH
, szFileName
);
97 GetPrivateProfileStringW(NT_PARAMS
, L
"TmpDirName", NULL
, szTempDirName
, 50, szFileName
);
98 GetPrivateProfileStringW(NT_PARAMS
, L
"CmdLine", NULL
, szCmdLine
, MAX_PATH
, szFileName
);
100 wcscpy(szCabFilePath
, szSetupPath
);
101 wcscat(szCabFilePath
, szCabFileName
);
103 /* ceate temp directory */
104 GetSystemDrive(szDrive
);
105 wcscpy(szTempPath
, szDrive
);
106 wcscat(szTempPath
, MSSETUP_PATH
);
107 wcscpy(szFullTempPath
, szTempPath
);
108 wcscat(szFullTempPath
, szTempDirName
);
109 wcscat(szFullTempPath
, L
"\\");
111 if (SHCreateDirectoryEx(0, szFullTempPath
, NULL
) != ERROR_SUCCESS
)
113 MessageBoxW(0, L
"Could not create Temp Directory.", L
"Error", MB_OK
| MB_ICONERROR
);
117 dwAttrib
= GetFileAttributes(szTempPath
);
118 SetFileAttributes(szTempPath
, dwAttrib
| FILE_ATTRIBUTE_HIDDEN
);
121 if (!SetupIterateCabinetW(szCabFilePath
, 0, ExtCabCallback
, szFullTempPath
))
123 MessageBoxW(0, L
"Could not extract cab file", L
"Error", MB_OK
| MB_ICONERROR
);
124 DeleteDirectory(szTempPath
);
128 /* prepare command line */
129 wsprintf(szTempCmdLine
, szCmdLine
, szFullTempPath
, lpCmdLine
);
130 wcscpy(szCmdLine
, szFullTempPath
);
131 wcscat(szCmdLine
, szTempCmdLine
);
133 /* execute the 32-Bit installer */
134 ZeroMemory(&processInfo
, sizeof(processInfo
));
135 ZeroMemory(&startupInfo
, sizeof(startupInfo
));
136 startupInfo
.cb
= sizeof(startupInfo
);
137 if (CreateProcessW(NULL
, szCmdLine
, NULL
, NULL
, FALSE
, NORMAL_PRIORITY_CLASS
, NULL
, szFullTempPath
, &startupInfo
, &processInfo
))
139 WaitForSingleObject(processInfo
.hProcess
, INFINITE
);
140 CloseHandle(processInfo
.hProcess
);
141 CloseHandle(processInfo
.hThread
);
145 WCHAR szMsg
[MAX_PATH
];
146 wsprintf(szMsg
, L
"Failed to load the installer. Error %d", GetLastError());
147 MessageBoxW(0, szMsg
, L
"Error", MB_OK
| MB_ICONERROR
);
148 DeleteDirectory(szTempPath
);
153 DeleteDirectory(szTempPath
);