Author: ekohl
Date: Sun Jul 2 01:01:59 2006
New Revision: 22745
URL:
http://svn.reactos.org/svn/reactos?rev=22745&view=rev
Log:
Enable CM_Connect_MachineW to connect to the local machine.
Modified:
trunk/reactos/dll/win32/setupapi/cfgmgr.c
Modified: trunk/reactos/dll/win32/setupapi/cfgmgr.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/setupapi/cfgmgr.…
==============================================================================
--- trunk/reactos/dll/win32/setupapi/cfgmgr.c (original)
+++ trunk/reactos/dll/win32/setupapi/cfgmgr.c Sun Jul 2 01:01:59 2006
@@ -42,6 +42,7 @@
WCHAR szMachineName[MAX_PATH];
RPC_BINDING_HANDLE BindingHandle;
HSTRING_TABLE StringTable;
+ BOOL bLocal;
} MACHINE_INFO, *PMACHINE_INFO;
@@ -251,33 +252,48 @@
TRACE("%s %p\n", debugstr_w(UNCServerName), phMachine);
- if (!UNCServerName)
- {
- FIXME("Connection to local machine not implemented\n");
- *phMachine = NULL;
- return CR_SUCCESS;
- }
+ if (phMachine == NULL)
+ return CR_INVALID_POINTER;
+
+ *phMachine = NULL;
pMachine = HeapAlloc(GetProcessHeap(), 0, sizeof(MACHINE_INFO));
if (pMachine == NULL)
return CR_OUT_OF_MEMORY;
- lstrcpyW(pMachine->szMachineName, UNCServerName);
-
- pMachine->StringTable = StringTableInitialize();
- if (pMachine->StringTable == NULL)
- {
- HeapFree(GetProcessHeap(), 0, pMachine);
- return CR_FAILURE;
- }
-
- StringTableAddString(pMachine->StringTable, L"PLT", 1);
-
- if (!PnpBindRpc(UNCServerName, &pMachine->BindingHandle))
- {
- StringTableDestroy(pMachine->StringTable);
- HeapFree(GetProcessHeap(), 0, pMachine);
- return CR_INVALID_MACHINENAME;
+ if (UNCServerName == NULL || *UNCServerName == 0)
+ {
+ pMachine->bLocal = TRUE;
+
+ /* FIXME: store the computers name in pMachine->szMachineName */
+
+ if (!PnpGetLocalHandles(&pMachine->BindingHandle,
+ &pMachine->StringTable))
+ {
+ HeapFree(GetProcessHeap(), 0, pMachine);
+ return CR_FAILURE;
+ }
+ }
+ else
+ {
+ pMachine->bLocal = FALSE;
+ lstrcpyW(pMachine->szMachineName, UNCServerName);
+
+ pMachine->StringTable = StringTableInitialize();
+ if (pMachine->StringTable == NULL)
+ {
+ HeapFree(GetProcessHeap(), 0, pMachine);
+ return CR_FAILURE;
+ }
+
+ StringTableAddString(pMachine->StringTable, L"PLT", 1);
+
+ if (!PnpBindRpc(UNCServerName, &pMachine->BindingHandle))
+ {
+ StringTableDestroy(pMachine->StringTable);
+ HeapFree(GetProcessHeap(), 0, pMachine);
+ return CR_INVALID_MACHINENAME;
+ }
}
phMachine = (PHMACHINE)pMachine;
@@ -551,11 +567,14 @@
if (pMachine == NULL)
return CR_SUCCESS;
- if (pMachine->StringTable != NULL)
- StringTableDestroy(pMachine->StringTable);
-
- if (!PnpUnbindRpc(pMachine->BindingHandle))
- return CR_ACCESS_DENIED;
+ if (pMachine->bLocal == FALSE)
+ {
+ if (pMachine->StringTable != NULL)
+ StringTableDestroy(pMachine->StringTable);
+
+ if (!PnpUnbindRpc(pMachine->BindingHandle))
+ return CR_ACCESS_DENIED;
+ }
HeapFree(GetProcessHeap(), 0, pMachine);