5 #define NT_PARAMS L"NT3.51 Intel Params"
6 #define MSSETUP_PATH L"~MSSETUP.T\\"
8 static UINT WINAPI
ExtCabCallback(PVOID Context
, UINT Notification
, UINT_PTR Param1
, UINT_PTR Param2
)
10 FILE_IN_CABINET_INFO_W
*pInfo
;
11 FILEPATHS_W
*pFilePaths
;
15 case SPFILENOTIFY_FILEINCABINET
:
16 pInfo
= (FILE_IN_CABINET_INFO_W
*)Param1
;
17 wcscpy(pInfo
->FullTargetName
, (LPCWSTR
)Context
);
18 wcscat(pInfo
->FullTargetName
, pInfo
->NameInCabinet
);
20 case SPFILENOTIFY_FILEEXTRACTED
:
21 pFilePaths
= (FILEPATHS_W
*)Param1
;
27 BOOL
DeleteDirectory(LPWSTR lpszDir
)
29 DWORD len
= wcslen(lpszDir
);
30 WCHAR
*pszFrom
= HeapAlloc(GetProcessHeap(), 0, (len
+ 2) * sizeof(WCHAR
));
31 wcscpy(pszFrom
, lpszDir
);
35 SHFILEOPSTRUCT fileop
;
37 fileop
.wFunc
= FO_DELETE
;
38 fileop
.pFrom
= pszFrom
;
40 fileop
.fFlags
= FOF_NOCONFIRMATION
|FOF_SILENT
;
41 fileop
.fAnyOperationsAborted
= FALSE
;
42 fileop
.lpszProgressTitle
= NULL
;
43 fileop
.hNameMappings
= NULL
;
45 int ret
= SHFileOperation(&fileop
);
46 HeapFree(GetProcessHeap(), 0, &pszFrom
);
50 VOID
GetSystemDrive(LPWSTR lpszDrive
)
52 WCHAR szWindir
[MAX_PATH
];
53 GetWindowsDirectoryW(szWindir
, MAX_PATH
);
54 _wsplitpath(szWindir
, lpszDrive
, NULL
, NULL
, NULL
);
55 wcscat(lpszDrive
, L
"\\");
58 int APIENTRY
wWinMain(HINSTANCE hInstance
,
59 HINSTANCE hPrevInstance
,
63 UNREFERENCED_PARAMETER(hPrevInstance
);
64 UNREFERENCED_PARAMETER(nCmdShow
);
66 WCHAR szSetupPath
[MAX_PATH
];
67 WCHAR szFileName
[MAX_PATH
];
68 WCHAR szCabFileName
[MAX_PATH
];
69 WCHAR szCabFilePath
[MAX_PATH
];
70 WCHAR szTempDirName
[50];
71 WCHAR szCmdLine
[MAX_PATH
];
72 WCHAR szTempCmdLine
[MAX_PATH
];
73 WCHAR szTempPath
[MAX_PATH
];
74 WCHAR szFullTempPath
[MAX_PATH
];
77 PROCESS_INFORMATION processInfo
;
78 STARTUPINFO startupInfo
;
80 GetCurrentDirectory(MAX_PATH
, szSetupPath
);
81 wcscat(szSetupPath
, L
"\\");
82 wcscpy(szFileName
, szSetupPath
);
83 wcscat(szFileName
, L
"setup.lst");
85 /* read information from setup.lst */
86 GetPrivateProfileStringW(NT_PARAMS
, L
"CabinetFile", NULL
, szCabFileName
, MAX_PATH
, szFileName
);
87 GetPrivateProfileStringW(NT_PARAMS
, L
"TmpDirName", NULL
, szTempDirName
, 50, szFileName
);
88 GetPrivateProfileStringW(NT_PARAMS
, L
"CmdLine", NULL
, szCmdLine
, MAX_PATH
, szFileName
);
90 wcscpy(szCabFilePath
, szSetupPath
);
91 wcscat(szCabFilePath
, szCabFileName
);
93 /* ceate temp directory */
94 GetSystemDrive(szDrive
);
95 wcscpy(szTempPath
, szDrive
);
96 wcscat(szTempPath
, MSSETUP_PATH
);
97 wcscpy(szFullTempPath
, szTempPath
);
98 wcscat(szFullTempPath
, szTempDirName
);
99 wcscat(szFullTempPath
, L
"\\");
101 if (SHCreateDirectoryEx(0, szFullTempPath
, NULL
) != ERROR_SUCCESS
)
103 MessageBoxW(0, L
"Could not create Temp Directory.", L
"Error", MB_OK
| MB_ICONERROR
);
107 dwAttrib
= GetFileAttributes(szTempPath
);
108 SetFileAttributes(szTempPath
, dwAttrib
| FILE_ATTRIBUTE_HIDDEN
);
111 if (!SetupIterateCabinetW(szCabFilePath
, 0, ExtCabCallback
, szFullTempPath
))
113 MessageBoxW(0, L
"Could not extract cab file", L
"Error", MB_OK
| MB_ICONERROR
);
114 DeleteDirectory(szTempPath
);
118 /* prepare command line */
119 wsprintf(szTempCmdLine
, szCmdLine
, szFullTempPath
, lpCmdLine
);
120 wcscpy(szCmdLine
, szFullTempPath
);
121 wcscat(szCmdLine
, szTempCmdLine
);
123 /* execute the 32-Bit installer */
124 ZeroMemory(&processInfo
, sizeof(processInfo
));
125 ZeroMemory(&startupInfo
, sizeof(startupInfo
));
126 startupInfo
.cb
= sizeof(startupInfo
);
127 if (CreateProcessW(NULL
, szCmdLine
, NULL
, NULL
, FALSE
, NORMAL_PRIORITY_CLASS
, NULL
, szFullTempPath
, &startupInfo
, &processInfo
))
129 WaitForSingleObject(processInfo
.hProcess
, INFINITE
);
130 CloseHandle(processInfo
.hProcess
);
131 CloseHandle(processInfo
.hThread
);
135 WCHAR szMsg
[MAX_PATH
];
136 wsprintf(szMsg
, L
"Failed to load the installer. Error %d", GetLastError());
137 MessageBoxW(0, szMsg
, L
"Error", MB_OK
| MB_ICONERROR
);
138 DeleteDirectory(szTempPath
);
143 DeleteDirectory(szTempPath
);