mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-09-02 12:23:31 +00:00
[DEVMGR]
- NEVER EVER use single line if statements!!!! - Fix indentation and coding style. svn path=/trunk/; revision=73852
This commit is contained in:
@@ -114,7 +114,6 @@ CClassNode::ConvertResourceDescriptorToString(
|
||||
DWORD Size;
|
||||
DWORD dwError;
|
||||
|
||||
|
||||
// First check for a semi colon */
|
||||
ptr = wcschr(ResourceDescriptor, L';');
|
||||
if (ptr)
|
||||
@@ -127,15 +126,18 @@ CClassNode::ConvertResourceDescriptorToString(
|
||||
{
|
||||
// This must be a dll resource based descriptor. Find the comma
|
||||
ptr = wcschr(ResourceDescriptor, L',');
|
||||
if (ptr == NULL) return ERROR_INVALID_DATA;
|
||||
if (ptr == NULL)
|
||||
return ERROR_INVALID_DATA;
|
||||
|
||||
// Terminate the string where the comma was
|
||||
*ptr = UNICODE_NULL;
|
||||
|
||||
// Expand any environment strings
|
||||
Size = ExpandEnvironmentStringsW(&ResourceDescriptor[1], ModulePath, MAX_PATH);
|
||||
if (Size > MAX_PATH) return ERROR_BUFFER_OVERFLOW;
|
||||
if (Size == 0) return GetLastError();
|
||||
if (Size > MAX_PATH)
|
||||
return ERROR_BUFFER_OVERFLOW;
|
||||
if (Size == 0)
|
||||
return GetLastError();
|
||||
|
||||
// Put the comma back and move past it
|
||||
*ptr = L',';
|
||||
@@ -143,13 +145,15 @@ CClassNode::ConvertResourceDescriptorToString(
|
||||
|
||||
// Load the dll
|
||||
hModule = LoadLibraryExW(ModulePath, NULL, LOAD_LIBRARY_AS_DATAFILE);
|
||||
if (hModule == NULL) return GetLastError();
|
||||
if (hModule == NULL)
|
||||
return GetLastError();
|
||||
|
||||
// Convert the resource id to a number
|
||||
ResourceId = _wtoi(ptr);
|
||||
|
||||
// If the number is negative, make it positive
|
||||
if (ResourceId < 0) ResourceId = -ResourceId;
|
||||
if (ResourceId < 0)
|
||||
ResourceId = -ResourceId;
|
||||
|
||||
// Load the string from the dll
|
||||
if (LoadStringW(hModule, ResourceId, ResString, 256))
|
||||
|
||||
@@ -41,7 +41,6 @@ CDeviceNode::CDeviceNode(
|
||||
size_t size = wcslen(Node.m_DeviceId) + 1;
|
||||
m_DeviceId = new WCHAR[size];
|
||||
StringCbCopyW(m_DeviceId, size * sizeof(WCHAR), Node.m_DeviceId);
|
||||
|
||||
}
|
||||
|
||||
CDeviceNode::~CDeviceNode()
|
||||
@@ -65,15 +64,14 @@ CDeviceNode::SetupNode()
|
||||
|
||||
// Now get the actual device id
|
||||
cr = CM_Get_Device_IDW(m_DevInst,
|
||||
m_DeviceId,
|
||||
ulLength + 1,
|
||||
0);
|
||||
m_DeviceId,
|
||||
ulLength + 1,
|
||||
0);
|
||||
if (cr != CR_SUCCESS || wcscmp(m_DeviceId, L"HTREE\\ROOT\\0") == 0)
|
||||
{
|
||||
delete[] m_DeviceId;
|
||||
m_DeviceId = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Make sure we got the string
|
||||
@@ -95,7 +93,6 @@ CDeviceNode::SetupNode()
|
||||
&m_DevinfoData);
|
||||
}
|
||||
|
||||
|
||||
// Check if the device has a problem
|
||||
if (HasProblem())
|
||||
{
|
||||
@@ -109,9 +106,6 @@ CDeviceNode::SetupNode()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Get the class guid for this device
|
||||
ulLength = MAX_GUID_STRING_LEN * sizeof(WCHAR);
|
||||
cr = CM_Get_DevNode_Registry_PropertyW(m_DevInst,
|
||||
@@ -131,13 +125,11 @@ CDeviceNode::SetupNode()
|
||||
m_ClassGuid = GUID_DEVCLASS_UNKNOWN;
|
||||
}
|
||||
|
||||
|
||||
// Get the image for the class this device is in
|
||||
SetupDiGetClassImageIndex(m_ImageListData,
|
||||
&m_ClassGuid,
|
||||
&m_ClassImage);
|
||||
|
||||
|
||||
// Get the description for the device
|
||||
ulLength = DISPLAY_NAME_LEN * sizeof(WCHAR);
|
||||
cr = CM_Get_DevNode_Registry_PropertyW(m_DevInst,
|
||||
@@ -155,7 +147,6 @@ CDeviceNode::SetupNode()
|
||||
m_DisplayName,
|
||||
&ulLength,
|
||||
0);
|
||||
|
||||
}
|
||||
|
||||
if (cr != CR_SUCCESS)
|
||||
@@ -311,7 +302,6 @@ CDeviceNode::EnableDevice(
|
||||
pcp.StateChange = (Enable ? DICS_ENABLE : DICS_DISABLE);
|
||||
pcp.HwProfile = 0;
|
||||
|
||||
|
||||
// check both scopes to make sure we can make the change
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
@@ -374,7 +364,6 @@ CDeviceNode::EnableDevice(
|
||||
bool
|
||||
CDeviceNode::UninstallDevice()
|
||||
{
|
||||
|
||||
if (CanUninstall() == false)
|
||||
return false;
|
||||
|
||||
@@ -389,7 +378,6 @@ CDeviceNode::UninstallDevice()
|
||||
// device and ask if they're happy with the uninstall
|
||||
//
|
||||
|
||||
|
||||
// Remove it
|
||||
SetupDiSetClassInstallParamsW(m_hDevInfo,
|
||||
&m_DevinfoData,
|
||||
@@ -404,7 +392,6 @@ CDeviceNode::UninstallDevice()
|
||||
0);
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/* PRIVATE METHODS ******************************************************/
|
||||
@@ -425,8 +412,7 @@ CDeviceNode::Cleanup()
|
||||
}
|
||||
|
||||
DWORD
|
||||
CDeviceNode::GetFlags(
|
||||
)
|
||||
CDeviceNode::GetFlags()
|
||||
{
|
||||
SP_DEVINSTALL_PARAMS DevInstallParams;
|
||||
DevInstallParams.cbSize = sizeof(SP_DEVINSTALL_PARAMS);
|
||||
@@ -480,5 +466,3 @@ CDeviceNode::RemoveFlags(
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -56,7 +56,8 @@ CDeviceView::Initialize()
|
||||
// Get the device image list
|
||||
m_ImageListData.cbSize = sizeof(SP_CLASSIMAGELIST_DATA);
|
||||
BOOL bSuccess = SetupDiGetClassImageList(&m_ImageListData);
|
||||
if (bSuccess == FALSE) return false;
|
||||
if (bSuccess == FALSE)
|
||||
return false;
|
||||
|
||||
// Create the main treeview
|
||||
m_hTreeView = CreateWindowExW(WS_EX_CLIENTEDGE,
|
||||
@@ -207,7 +208,6 @@ CDeviceView::Refresh(
|
||||
ThreadData->ScanForChanges = ScanForChanges;
|
||||
ThreadData->UpdateView = UpdateView;
|
||||
|
||||
|
||||
HANDLE hThread;
|
||||
hThread = (HANDLE)_beginthreadex(NULL,
|
||||
0,
|
||||
@@ -348,7 +348,8 @@ CDeviceView::GetNextClass(
|
||||
cr = CM_Enumerate_Classes(ClassIndex,
|
||||
ClassGuid,
|
||||
0);
|
||||
if (cr != CR_SUCCESS) return false;
|
||||
if (cr != CR_SUCCESS)
|
||||
return false;
|
||||
|
||||
// Check if this is the unknown class
|
||||
if (IsEqualGUID(*ClassGuid, GUID_DEVCLASS_UNKNOWN))
|
||||
@@ -422,7 +423,6 @@ unsigned int __stdcall CDeviceView::RefreshThread(void *Param)
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
This->SelectNode(LastSelectedNode);
|
||||
|
||||
delete ThreadData;
|
||||
@@ -645,7 +645,8 @@ CDeviceView::RecurseChildDevices(
|
||||
{
|
||||
// Check if the parent device has anything at the same level
|
||||
bSuccess = GetSiblingDevice(Device, &Device);
|
||||
if (bSuccess == FALSE) break;
|
||||
if (bSuccess == FALSE)
|
||||
break;
|
||||
|
||||
DeviceNode = dynamic_cast<CDeviceNode *>(GetDeviceNode(Device));
|
||||
if (DeviceNode == nullptr)
|
||||
@@ -686,7 +687,8 @@ CDeviceView::RecurseChildDevices(
|
||||
}
|
||||
|
||||
// If there was a problem, expand the ancestors
|
||||
if (HasProblem) return false;
|
||||
if (HasProblem)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -698,7 +700,8 @@ CDeviceView::EnableSelectedDevice(
|
||||
)
|
||||
{
|
||||
CDeviceNode *Node = dynamic_cast<CDeviceNode *>(GetSelectedNode());
|
||||
if (Node == nullptr) return false;
|
||||
if (Node == nullptr)
|
||||
return false;
|
||||
|
||||
if (Enable == false)
|
||||
{
|
||||
@@ -706,9 +709,9 @@ CDeviceView::EnableSelectedDevice(
|
||||
if (str.LoadStringW(g_hThisInstance, IDS_CONFIRM_DISABLE))
|
||||
{
|
||||
if (MessageBoxW(m_hMainWnd,
|
||||
str,
|
||||
Node->GetDisplayName(),
|
||||
MB_YESNO | MB_ICONWARNING | MB_DEFBUTTON2) != IDYES)
|
||||
str,
|
||||
Node->GetDisplayName(),
|
||||
MB_YESNO | MB_ICONWARNING | MB_DEFBUTTON2) != IDYES)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -724,7 +727,8 @@ CDeviceView::UpdateSelectedDevice(
|
||||
)
|
||||
{
|
||||
CDeviceNode *Node = dynamic_cast<CDeviceNode *>(GetSelectedNode());
|
||||
if (Node == nullptr) return false;
|
||||
if (Node == nullptr)
|
||||
return false;
|
||||
|
||||
DWORD dwReboot;
|
||||
if (InstallDevInst(m_hMainWnd, Node->GetDeviceId(), TRUE, &dwReboot))
|
||||
@@ -741,15 +745,16 @@ CDeviceView::UninstallSelectedDevice(
|
||||
)
|
||||
{
|
||||
CDeviceNode *Node = dynamic_cast<CDeviceNode *>(GetSelectedNode());
|
||||
if (Node == nullptr) return false;
|
||||
if (Node == nullptr)
|
||||
return false;
|
||||
|
||||
CAtlStringW str;
|
||||
if (str.LoadStringW(g_hThisInstance, IDS_CONFIRM_UNINSTALL))
|
||||
{
|
||||
if (MessageBoxW(m_hMainWnd,
|
||||
str,
|
||||
Node->GetDisplayName(),
|
||||
MB_YESNO | MB_ICONWARNING | MB_DEFBUTTON2) != IDYES)
|
||||
str,
|
||||
Node->GetDisplayName(),
|
||||
MB_YESNO | MB_ICONWARNING | MB_DEFBUTTON2) != IDYES)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -765,7 +770,8 @@ CDeviceView::RunAddHardwareWizard()
|
||||
HMODULE hModule;
|
||||
|
||||
hModule = LoadLibraryW(L"hdwwiz.cpl");
|
||||
if (hModule == NULL) return false;
|
||||
if (hModule == NULL)
|
||||
return false;
|
||||
|
||||
pAddHardwareWizard = (PADDHARDWAREWIZARD)GetProcAddress(hModule,
|
||||
"AddHardwareWizard");
|
||||
@@ -953,7 +959,8 @@ CDeviceView::RecurseFindDevice(
|
||||
|
||||
// Check if this node has any children
|
||||
hItem = TreeView_GetChild(m_hTreeView, hParentItem);
|
||||
if (hItem == NULL) return NULL;
|
||||
if (hItem == NULL)
|
||||
return NULL;
|
||||
|
||||
// The lParam contains the node pointer data
|
||||
tvItem.hItem = hItem;
|
||||
@@ -977,14 +984,16 @@ CDeviceView::RecurseFindDevice(
|
||||
|
||||
// This node may have its own children
|
||||
FoundItem = RecurseFindDevice(hItem, Node);
|
||||
if (FoundItem) return FoundItem;
|
||||
if (FoundItem)
|
||||
return FoundItem;
|
||||
|
||||
// Loop all the siblings
|
||||
for (;;)
|
||||
{
|
||||
// Get the next item at this level
|
||||
hItem = TreeView_GetNextSibling(m_hTreeView, hItem);
|
||||
if (hItem == NULL) break;
|
||||
if (hItem == NULL)
|
||||
break;
|
||||
|
||||
// The lParam contains the node pointer data
|
||||
tvItem.hItem = hItem;
|
||||
@@ -1007,7 +1016,8 @@ CDeviceView::RecurseFindDevice(
|
||||
|
||||
// This node may have its own children
|
||||
FoundItem = RecurseFindDevice(hItem, Node);
|
||||
if (FoundItem) return FoundItem;
|
||||
if (FoundItem)
|
||||
return FoundItem;
|
||||
}
|
||||
|
||||
return hItem;
|
||||
@@ -1022,7 +1032,8 @@ CDeviceView::SelectNode(
|
||||
|
||||
// Check if there are any items in the tree
|
||||
hRoot = TreeView_GetRoot(m_hTreeView);
|
||||
if (hRoot == NULL) return;
|
||||
if (hRoot == NULL)
|
||||
return;
|
||||
|
||||
// If we don't want to set select a node, just select root
|
||||
if (Node == nullptr || Node->GetNodeType() == RootNode)
|
||||
@@ -1060,7 +1071,8 @@ CDeviceView::GetClassNode(
|
||||
CClassNode *Node = nullptr;
|
||||
|
||||
Pos = m_ClassNodeList.GetHeadPosition();
|
||||
if (Pos == NULL) return nullptr;
|
||||
if (Pos == NULL)
|
||||
return nullptr;
|
||||
|
||||
do
|
||||
{
|
||||
@@ -1087,7 +1099,8 @@ CDeviceView::GetDeviceNode(
|
||||
CDeviceNode *Node = nullptr;
|
||||
|
||||
Pos = m_DeviceNodeList.GetHeadPosition();
|
||||
if (Pos == NULL) return nullptr;
|
||||
if (Pos == NULL)
|
||||
return nullptr;
|
||||
|
||||
do
|
||||
{
|
||||
@@ -1172,7 +1185,6 @@ CDeviceView::RefreshDeviceList()
|
||||
ClassIndex++;
|
||||
} while (Success);
|
||||
|
||||
|
||||
// Get all the devices on the local machine
|
||||
hDevInfo = SetupDiGetClassDevsW(NULL,
|
||||
0,
|
||||
@@ -1189,7 +1201,8 @@ CDeviceView::RefreshDeviceList()
|
||||
{
|
||||
// Get the devinst for this device
|
||||
Success = SetupDiEnumDeviceInfo(hDevInfo, i, &DeviceInfoData);
|
||||
if (Success == FALSE) break;
|
||||
if (Success == FALSE)
|
||||
break;
|
||||
|
||||
// create a new device node and add it to the list
|
||||
DeviceNode = new CDeviceNode(DeviceInfoData.DevInst, &m_ImageListData);
|
||||
@@ -1201,7 +1214,6 @@ CDeviceView::RefreshDeviceList()
|
||||
{
|
||||
ATLASSERT(FALSE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
SetupDiDestroyDeviceInfoList(hDevInfo);
|
||||
|
||||
@@ -93,7 +93,6 @@ CDeviceManager::~CDeviceManager(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
CDeviceManager::Create(_In_ HWND /*hWndParent*/,
|
||||
_In_ HINSTANCE hInst,
|
||||
@@ -132,7 +131,6 @@ CDeviceManager::Create(_In_ HWND /*hWndParent*/,
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* PRIVATE METHODS **********************************************/
|
||||
|
||||
bool
|
||||
@@ -256,11 +254,25 @@ CDeviceManager::RefreshView(_In_ ViewType Type,
|
||||
// Get the menu item id
|
||||
switch (Type)
|
||||
{
|
||||
case DevicesByType: CheckId = IDC_DEVBYTYPE; break;
|
||||
case DevicesByConnection: CheckId = IDC_DEVBYCONN; break;
|
||||
case ResourcesByType: CheckId = IDC_RESBYTYPE; break;
|
||||
case ResourcesByConnection: CheckId = IDC_RESBYCONN; break;
|
||||
default: ATLASSERT(FALSE); break;
|
||||
case DevicesByType:
|
||||
CheckId = IDC_DEVBYTYPE;
|
||||
break;
|
||||
|
||||
case DevicesByConnection:
|
||||
CheckId = IDC_DEVBYCONN;
|
||||
break;
|
||||
|
||||
case ResourcesByType:
|
||||
CheckId = IDC_RESBYTYPE;
|
||||
break;
|
||||
|
||||
case ResourcesByConnection:
|
||||
CheckId = IDC_RESBYCONN;
|
||||
break;
|
||||
|
||||
default:
|
||||
ATLASSERT(FALSE);
|
||||
break;
|
||||
}
|
||||
|
||||
// Set the new check item
|
||||
@@ -291,7 +303,8 @@ CDeviceManager::CreateToolBar(void)
|
||||
(HMENU)IDC_TOOLBAR,
|
||||
g_hThisInstance,
|
||||
NULL);
|
||||
if (m_hToolBar == NULL) return FALSE;
|
||||
if (m_hToolBar == NULL)
|
||||
return FALSE;
|
||||
|
||||
// Don't show clipped buttons
|
||||
SendMessageW(m_hToolBar,
|
||||
@@ -395,8 +408,6 @@ void CDeviceManager::UpdateToolbar()
|
||||
SendMessageW(m_hToolBar, TB_SETSTATE, IDC_DISABLE_DRV, MAKELPARAM(State, 0));
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool
|
||||
CDeviceManager::StatusBarLoadString(_In_ HWND hStatusBar,
|
||||
_In_ INT PartId,
|
||||
@@ -793,6 +804,7 @@ CDeviceManager::MainWndProc(_In_ HWND hwnd,
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_TIMER:
|
||||
{
|
||||
if (wParam == REFRESH_TIMER)
|
||||
@@ -829,9 +841,11 @@ CDeviceManager::MainWndProc(_In_ HWND hwnd,
|
||||
}
|
||||
|
||||
case WM_ACTIVATE:
|
||||
{
|
||||
if (LOWORD(hwnd))
|
||||
This->OnActivate();
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_DESTROY:
|
||||
{
|
||||
|
||||
@@ -31,7 +31,8 @@ CRootNode::SetupNode()
|
||||
HBITMAP hRootImage;
|
||||
hRootImage = LoadBitmapW(g_hThisInstance,
|
||||
MAKEINTRESOURCEW(IDB_ROOT_IMAGE));
|
||||
if (hRootImage == NULL) return FALSE;
|
||||
if (hRootImage == NULL)
|
||||
return false;
|
||||
|
||||
// Add this bitmap to the device image list. This is a bit hacky, but it's safe
|
||||
m_ClassImage = ImageList_Add(m_ImageListData->ImageList,
|
||||
|
||||
@@ -347,7 +347,7 @@ DriverDetailsDlgProc(IN HWND hwndDlg,
|
||||
|
||||
if (ListView_GetItemCount(hDriversListView) == 0)
|
||||
{
|
||||
if(LoadStringW(hDllInstance, IDS_NODRIVERS, szBuffer, _countof(szBuffer)))
|
||||
if (LoadStringW(hDllInstance, IDS_NODRIVERS, szBuffer, _countof(szBuffer)))
|
||||
MessageBoxW(hwndDlg, szBuffer, dap->szDevName, MB_OK);
|
||||
EndDialog(hwndDlg, IDCANCEL);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user