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 SHFILEOPSTRUCT fileop
;
30 DWORD len
= wcslen(lpszDir
);
31 WCHAR
*pszFrom
= HeapAlloc(GetProcessHeap(), 0, (len
+ 2) * sizeof(WCHAR
));
34 wcscpy(pszFrom
, lpszDir
);
39 fileop
.wFunc
= FO_DELETE
;
40 fileop
.pFrom
= pszFrom
;
42 fileop
.fFlags
= FOF_NOCONFIRMATION
|FOF_SILENT
;
43 fileop
.fAnyOperationsAborted
= FALSE
;
44 fileop
.lpszProgressTitle
= NULL
;
45 fileop
.hNameMappings
= NULL
;
47 ret
= SHFileOperation(&fileop
);
48 HeapFree(GetProcessHeap(), 0, &pszFrom
);
52 VOID
GetSystemDrive(LPWSTR lpszDrive
)
54 WCHAR szWindir
[MAX_PATH
];
55 GetWindowsDirectoryW(szWindir
, MAX_PATH
);
56 _wsplitpath(szWindir
, lpszDrive
, NULL
, NULL
, NULL
);
57 wcscat(lpszDrive
, L
"\\");
60 int APIENTRY
wWinMain(HINSTANCE hInstance
,
61 HINSTANCE hPrevInstance
,
65 WCHAR szSetupPath
[MAX_PATH
];
66 WCHAR szFileName
[MAX_PATH
];
67 WCHAR szCabFileName
[MAX_PATH
];
68 WCHAR szCabFilePath
[MAX_PATH
];
69 WCHAR szTempDirName
[50];
70 WCHAR szCmdLine
[MAX_PATH
];
71 WCHAR szTempCmdLine
[MAX_PATH
];
72 WCHAR szTempPath
[MAX_PATH
];
73 WCHAR szFullTempPath
[MAX_PATH
];
76 PROCESS_INFORMATION processInfo
;
77 STARTUPINFO startupInfo
;
78 UNREFERENCED_PARAMETER(hPrevInstance
);
79 UNREFERENCED_PARAMETER(nCmdShow
);
81 GetCurrentDirectory(MAX_PATH
, szSetupPath
);
82 wcscat(szSetupPath
, L
"\\");
83 wcscpy(szFileName
, szSetupPath
);
84 wcscat(szFileName
, L
"setup.lst");
86 /* read information from setup.lst */
87 GetPrivateProfileStringW(NT_PARAMS
, L
"CabinetFile", NULL
, szCabFileName
, MAX_PATH
, szFileName
);
88 GetPrivateProfileStringW(NT_PARAMS
, L
"TmpDirName", NULL
, szTempDirName
, 50, szFileName
);
89 GetPrivateProfileStringW(NT_PARAMS
, L
"CmdLine", NULL
, szCmdLine
, MAX_PATH
, szFileName
);
91 wcscpy(szCabFilePath
, szSetupPath
);
92 wcscat(szCabFilePath
, szCabFileName
);
94 /* ceate temp directory */
95 GetSystemDrive(szDrive
);
96 wcscpy(szTempPath
, szDrive
);
97 wcscat(szTempPath
, MSSETUP_PATH
);
98 wcscpy(szFullTempPath
, szTempPath
);
99 wcscat(szFullTempPath
, szTempDirName
);
100 wcscat(szFullTempPath
, L
"\\");
102 if (SHCreateDirectoryEx(0, szFullTempPath
, NULL
) != ERROR_SUCCESS
)
104 MessageBoxW(0, L
"Could not create Temp Directory.", L
"Error", MB_OK
| MB_ICONERROR
);
108 dwAttrib
= GetFileAttributes(szTempPath
);
109 SetFileAttributes(szTempPath
, dwAttrib
| FILE_ATTRIBUTE_HIDDEN
);
112 if (!SetupIterateCabinetW(szCabFilePath
, 0, ExtCabCallback
, szFullTempPath
))
114 MessageBoxW(0, L
"Could not extract cab file", L
"Error", MB_OK
| MB_ICONERROR
);
115 DeleteDirectory(szTempPath
);
119 /* prepare command line */
120 wsprintf(szTempCmdLine
, szCmdLine
, szFullTempPath
, lpCmdLine
);
121 wcscpy(szCmdLine
, szFullTempPath
);
122 wcscat(szCmdLine
, szTempCmdLine
);
124 /* execute the 32-Bit installer */
125 ZeroMemory(&processInfo
, sizeof(processInfo
));
126 ZeroMemory(&startupInfo
, sizeof(startupInfo
));
127 startupInfo
.cb
= sizeof(startupInfo
);
128 if (CreateProcessW(NULL
, szCmdLine
, NULL
, NULL
, FALSE
, NORMAL_PRIORITY_CLASS
, NULL
, szFullTempPath
, &startupInfo
, &processInfo
))
130 WaitForSingleObject(processInfo
.hProcess
, INFINITE
);
131 CloseHandle(processInfo
.hProcess
);
132 CloseHandle(processInfo
.hThread
);
136 WCHAR szMsg
[MAX_PATH
];
137 wsprintf(szMsg
, L
"Failed to load the installer. Error %d", GetLastError());
138 MessageBoxW(0, szMsg
, L
"Error", MB_OK
| MB_ICONERROR
);
139 DeleteDirectory(szTempPath
);
144 DeleteDirectory(szTempPath
);