//---------------------------------------------------------------------------- // // File: NetSetup.cpp // // Contents: This file contains the dll_main and Setup entry point // // // Notes: // // History: // July 8, 1995 MikeMi - Created // // //---------------------------------------------------------------------------- #include "pch.hxx" #pragma hdrstop HINSTANCE g_hinst = NULL; HIMAGELIST g_hil = NULL; #ifdef STATICBITMAPINRCFAILS HBITMAP g_hbmWizard = NULL; HBITMAP g_hbmSrvWizard; HBITMAP g_hbmWksWizard; HBITMAP g_hbmWizInternet = NULL; #endif HIMAGELIST g_hilItemIcons = NULL; HIMAGELIST g_hilCheckIcons = NULL; static NETPAGESINFO g_npi; #if defined( CAIRO ) const INT g_cPages = 10; #else const INT g_cPages = 14; #endif // // directories // const WCHAR PSZ_SYSDIR[] = L"\\SYSTEM32"; const WCHAR PSZ_INFDIR[] = L"\\SYSTEM32"; //------------------------------------------------------------------- // // Function: DLLMain // // Synopsis: // Entry point for all DLLs // // Notes: // // History; // July 8, 1995 MikeMi - // //------------------------------------------------------------------- BOOL APIENTRY DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) { BOOL frt = TRUE; switch (dwReason) { case DLL_PROCESS_ATTACH: g_hinst = hInstance; g_hbmWizard = NULL; g_hbmWksWizard = LoadBitmap( g_hinst, MAKEINTRESOURCE( IDB_NETWIZARD ) ); g_hbmSrvWizard = LoadBitmap( g_hinst, MAKEINTRESOURCE( IDB_SRVWIZARD ) ); g_hbmWizInternet = LoadBitmap( g_hinst, MAKEINTRESOURCE( IDB_INTERNET_SERVER ) ); g_hilItemIcons = ImageList_LoadBitmap( GetModuleHandle( PSZ_IMAGERESOURCE_DLL ), MAKEINTRESOURCE( IDB_IMAGELIST ), 16, 0, PALETTEINDEX( 6 ) ); g_hilCheckIcons = ImageList_LoadBitmap( g_hinst, MAKEINTRESOURCE( IDB_CHECKSTATE ), 16, 0, PALETTEINDEX( 6 ) ); break; case DLL_PROCESS_DETACH: DeleteObject( g_hbmWksWizard ); DeleteObject( g_hbmSrvWizard ); DeleteObject( g_hbmWizInternet ); ImageList_Destroy( g_hilItemIcons ); ImageList_Destroy( g_hilCheckIcons ); break; case DLL_THREAD_ATTACH: break; case DLL_THREAD_DETACH: break; default: break; } return( frt ); } //------------------------------------------------------------------- // // Function: // // Synopsis: // // Arguments: // // Return; // // Notes: // // History: // July 8, 1995 MikeMi - Created // // //------------------------------------------------------------------- void ToggleLVItemState( HWND hwndLV, INT iItem, INT& cItemsChecked, NETPAGESINFO* pgp ) { LV_ITEM lvItem; UINT state; UINT stateMask; BOOL fInstall; InfProduct* pinfp; // we are interested in is the PARAM lvItem.iItem = iItem; lvItem.mask = LVIF_PARAM; lvItem.iSubItem = 0; ListView_GetItem( hwndLV, &lvItem ); pinfp = (InfProduct*)lvItem.lParam; // toggle install flag, set focus to item clicked state = LVIS_FOCUSED | LVIS_SELECTED; stateMask = LVIS_FOCUSED | LVIS_SELECTED; if (!pinfp->IsReadOnly()) { if (pinfp->IsInstalled()) { fInstall = pinfp->ShouldRemove(); pinfp->SetRemove( !fInstall ); } else { fInstall = !pinfp->ShouldInstall(); pinfp->SetInstall( fInstall ); } // special case IIS/PWS // if (0 == lstrcmpi( pinfp->QueryOption(), PSZ_IIS_OPTION )) { IncludeComponent( PSZ_TCPIP_OPTION, pgp->dlinfUIProtocols, pgp->dlinfAllProtocols, fInstall ); } stateMask |= LVIS_STATEIMAGEMASK; // update list to reflect state change if (fInstall) { state |= INDEXTOSTATEIMAGEMASK( SELS_CHECKED ); cItemsChecked++; } else { state |= INDEXTOSTATEIMAGEMASK( SELS_UNCHECKED ); cItemsChecked--; } } ListView_SetItemState( hwndLV, iItem, state, stateMask ); } //------------------------------------------------------------------- // // Function: // // Synopsis: // // Arguments: // hwndDlg [in] - handle of Dialog window // // Return; // // Notes: // // History: // //------------------------------------------------------------------- INT OnListClick( HWND hwndDlg, HWND hwndLV, BOOL fDouble, INT& cItemsChecked, NETPAGESINFO* pgp ) { INT iItem; InfProduct* pinfp; DWORD dwpts; RECT rc; LV_HITTESTINFO lvhti; // we have the location dwpts = GetMessagePos(); // translate it relative to the listview GetWindowRect( hwndLV, &rc ); lvhti.pt.x = LOWORD( dwpts ) - rc.left; lvhti.pt.y = HIWORD( dwpts ) - rc.top; // get currently selected item iItem = ListView_HitTest( hwndLV, &lvhti ); // if no selection, or click not on state return false if (-1 != iItem) { if ( fDouble ) { if ((LVHT_ONITEMICON != (LVHT_ONITEMICON & lvhti.flags)) && (LVHT_ONITEMLABEL != (LVHT_ONITEMLABEL & lvhti.flags)) && (LVHT_ONITEMSTATEICON != (LVHT_ONITEMSTATEICON & lvhti.flags)) ) { iItem = -1; } } else { if (LVHT_ONITEMSTATEICON != (LVHT_ONITEMSTATEICON & lvhti.flags)) { iItem = -1; } } if (-1 != iItem) { ToggleLVItemState( hwndLV, iItem, cItemsChecked, pgp ); } } return( iItem ); } //------------------------------------------------------------------- // // Function: // // Synopsis: // // Arguments: // hwndDlg [in] - handle of Dialog window // // Return; // // Notes: // // History: // //------------------------------------------------------------------- INT OnListKeyDown( HWND hwndDlg, HWND hwndLV, WORD wVKey, INT& cItemsChecked, NETPAGESINFO* pgp ) { INT iItem = -1; if (VK_SPACE == wVKey) { iItem = ListView_GetNextItem( hwndLV, -1, LVNI_FOCUSED | LVNI_SELECTED ); // if no selection if (-1 != iItem) { ToggleLVItemState( hwndLV, iItem, cItemsChecked, pgp ); } } return( iItem ); } //------------------------------------------------------------------- // // Function: // // Synopsis: // // Arguments: // // Return; // // Notes: // // History: // // //------------------------------------------------------------------- static const WCHAR pszActiveComputerNameKey[] = L"SYSTEM\\CurrentControlSet\\Control\\ComputerName\\ActiveComputerName"; static const WCHAR pszComputerNameKey[] = L"SYSTEM\\CurrentControlSet\\Control\\ComputerName\\ComputerName"; static const WCHAR pszComputerNameValue[] = L"ComputerName"; BOOL SetActiveComputerName( PCWSTR pszNewName ) { HKEY hkeyActive; HKEY hkeyIntended; WCHAR pszTemp[MAX_COMPUTERNAME_LENGTH+1]; DWORD cbSize; DWORD dwType; LONG lrt; // open the keys we need lrt = RegOpenKeyEx( HKEY_LOCAL_MACHINE, pszActiveComputerNameKey, 0, KEY_ALL_ACCESS, &hkeyActive ); lrt = RegOpenKeyEx( HKEY_LOCAL_MACHINE, pszComputerNameKey, 0, KEY_ALL_ACCESS, &hkeyIntended ); if (pszNewName == NULL) { // read computer name cbSize = sizeof( WCHAR ) * (MAX_COMPUTERNAME_LENGTH + 1); lrt = RegQueryValueEx( hkeyIntended, pszComputerNameValue, NULL, &dwType, (LPBYTE)pszTemp, &cbSize ); pszNewName = pszTemp; } else { cbSize = sizeof( WCHAR ) * (lstrlen( pszNewName ) + 1); // set the intended computer name lrt = RegSetValueEx( hkeyIntended, pszComputerNameValue, 0, REG_SZ, (LPBYTE)pszNewName, cbSize ); } // set the active computer name lrt = RegSetValueEx( hkeyActive, pszComputerNameValue, 0, REG_SZ, (LPBYTE)pszNewName, cbSize ); // close it all up RegCloseKey( hkeyActive ); RegCloseKey( hkeyIntended ); return (lrt == 0); } //------------------------------------------------------------------- // // Function: RegEntriesForNetDetect // // Synopsis: Use Setupapi's entry pts to parse the inf file// If an error occurs on ny line, we ignore the // whole line. Hopefully, it should not appear in // the registry as well, because RegCloseKey is // called only if all went well. BUGBUG, check // that the Registry is actually not committed // until RegFlushKey/RegCloseKey is called. // // Arguments: // [in] HINF hinf, handle to the netoemdh.inf // [in] PINFCONTEXT pinfc, inf parsed by setup // [in] enum BUSTYPE busType, EISA/MCI/PCI // [in] LPTSTR pszKey Reg key to whatever bus // type we're reading about // Return: // None // Notes: // The format of netoemdh.inf is as follows // [EISA] //