|
My provider is a DLL, I tried attaching it to Internet Explorer but didn't work even after placing breakpoints in the Initialize method of IWbemProviderInit.
I am creating a new WMI Management object with its WMI provider, the class will only do enumeration. Let me check how it goes, I guess it will take me half an hour to try out all the above permutation and combinations. Will definitely get back.
|
|
|
|
|
I just Googled for "debug wmi provider dll". Found a couple of things:
From Wikipedia:
WinMgmt.exe: WinMgmt.exe is not a tool; it is the executable that implements the WMI Core service. Under the Windows NT family of operating systems, WMI runs as a service. On computers running Windows 98, Windows 95 or Windows Me, WMI runs as an application. Under the Windows NT family of operating systems, it is also possible to run this executable as an application, in which case, the executable runs in the current user context. For this, the WMI service must be stopped first. The executable supports some switches that can be useful when starting WMI as a service or as an application. WMI provider developers who may want to debug their providers essentially need to run the WMI service as an application.
From this CodeProject article[^]:
Debugging WMI provider critta 4:39 11 Jan '06
Step 1:
stop the Windows Management Instrumentation Service
(control panel-->administrative tools---> services, or Start-->Run--> services.msc)
Step 2:
In your VS click go to Build/Start Debug / Go, a dialog appears and asks for "Executable for Debug Session" here specify the path to the winmgmt.exe (should be under %systemroot%/system32/wbem.
That's it !
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Tried attaching it to winmgmt.exe, I get the following critical error and debugging stops.
"Debugging information for 'winmgmt.exe' cannot be found or does not match. No symbols loaded."
|
|
|
|
|
I tried again by creating a simple management class which only supports enumeration. Same problem "WMI:Provider load failure", the MOF file and Enumeration function code is below:
MOF File
---------
#pragma namespace("\\\\.\\root")
Instance of __Namespace
{
Name = "KI";
};
#pragma namespace("\\\\.\\root\\KI")
instance of __Win32Provider as $P
{
Name = "KI_Country";
ClsId = "{8A203B80-841D-4274-B753-8A30D8AB862D}";
ClientLoadableCLSID = NULL;
DefaultMachineName = NULL;
ImpersonationLevel = 1;
InitializationReentrancy = 0;
InitializeAsAdminFirst = FALSE;
PerLocaleInitialization = FALSE;
PerUserInitialization = TRUE;
Pure = TRUE;
UnloadTimeout = NULL;
HostingModel = "LocalServiceHost";
};
instance of __InstanceProviderRegistration
{
Provider = $P;
SupportsGet = TRUE;
SupportsEnumeration = TRUE;
};
[
dynamic: ToInstance,
provider("KI_Country"): ToInstance
]
class Country
{
[key] string Name;
uint8 Population;
};
Source code for method for enumeration
---------------------------------------
void CCKICountry::OnCountryInstances(CWbemInstanceList& instList, LPWBEMMETHODCTX ptrs)
{
// Create instance!
LPWBEMINSTANCE pInst = CreateWbemInstance(ptrs);
if (pInst)
{
CComVariant varCapacity(11);
varCapacity.ChangeType(VT_UI1);
// Set property
pInst->SetProperty(L"Name", L"Argentina");
pInst->SetProperty(L"Population", varCapacity);
instList.Add(pInst);
pInst->SetProperty(L"Name", L"Brazil");
pInst->SetProperty(L"Population", varCapacity);
instList.Add(pInst);
}
}
IDL definition
---------------
import "oaidl.idl";
import "ocidl.idl";
import "wbemprov.idl";
[
object,
uuid(7E9375F5-7033-4991-9602-1A406A8BDED5),
helpstring("ICKICountry Interface"),
pointer_default(unique)
]
interface ICKICountry : IUnknown{
};
[
uuid(8A203B80-841D-4274-B753-8A30D8AB862D),
version(1.0),
helpstring("Test4 1.0 Type Library")
]
library Test4Lib
{
importlib("stdole2.tlb");
[
uuid(397891B8-804F-45E6-9D8D-2AF808AE2B49),
helpstring("CKICountry Class")
]
coclass CKICountry
{
[default] interface IWbemProviderInit;
interface IWbemServices;
};
};
|
|
|
|
|
I was able to remove the error "WMI:Provider load failuer". The problem was with the CLSID, in the MOF I was using the wrong CLSID. rectified it and now I am not getting this error.
But I am still not able to get into the debugger, for debugging I have tried using "wmic.exe" from command line. E.g.,
>wmic /NAMESPACE:\\root\KI path "Country" get name
this returns me the result.
I have tried to attach to "wmic.exe" and "cmd.exe", both didn't work.
One thing I noted was that the breakpoint shows up as a empty ring with warning sign, the message being displayed in tool tip is "The breakpoint will not be currently hit. No symbols have been loaded for the document."
Any pointers?
|
|
|
|
|
|
Ooh...I tried the as mentioned in the "Microsoft's instructions for debugging a DLL".
I have specified "C:\WINDOWS\System32\Wbem\wmic.exe", when debugging is started it opens a command prompt. In the command prompt I type:
wmic:root\cli> /NAMESPACE:\\root\KI path "Country" get name
I get the output, but does not enter debugger. I think wmic.exe does not create the DLL, how do I figure which executable or DLL is hosting my DLL in process? Possibly point to that executable in project properties may help.
|
|
|
|
|
Hey, Got it working.
Attached the process to "wmiprvse.exe" instead of specifying the command line. Now able to debug.
Thanks Stuart for all the help, your pointers helped me be on track.
Thanks once again.
|
|
|
|
|
Excellent Now you've got the debugging working, you can get back to the primary problem - i.e. getting the provider working
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hey Stuart,
Hope you enjoyed the weekend.
Now in my OnxxxInstance() method I am trying to set the WMI property EWFUsage which is defined as uint32. I keep getting error 0x80041005, the error seems to be related with the setting up of variant variable.
My code looks something like this in OnxxxInstance()
pInst->SetProperty<UINT32>(L"EWFUsage", 11);
I tried as below also:
CComVariant varValue(11);
varValue.ChangeType(VT_UI4);
pInst->SetProperty(L"EWFUsage",varValue);
|
|
|
|
|
krishiyengar wrote: I keep getting error 0x80041005
What statement actually raises the error?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
When I am setting the WMI property value, I get the error. The method SetProperty() raises the error.
void CTL_Memory::OnMemoryInstances(CWbemInstanceList& instList, LPWBEMMETHODCTX ptrs)
{
// Create instance!
LPWBEMINSTANCE pInst = CreateWbemInstance(ptrs);
if (pInst)
{
CComVariant varValue(11ul);
varValue.ChangeType(VT_UI8);
//varValue.ullVal = 0l;
pInst->SetProperty(L"EWFUsage",UINT32(11));
instList.Add(pInst);
}
}
|
|
|
|
|
When I change the code to :
pInst->SetProperty(L"EWFUsage",int(11));
I.e., intead of casting it as UINT32 I cast it to int() then it works. My other property values are 64 bit, which data type casting will I be required to use?
|
|
|
|
|
__int64?
Look at the source code for the WMI Provider framework you're using - that should define the mappings between C++ types and VARIANT types.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I checked the atlcomcli.h file, which defines the C++ to VARIANT mappings.
In order to support uint64 I have _ATL_SUPPORT_VT_I8 defined in stdAfx.h file, the code snippet from atlcomcli.h based on which I defined the directive is :
#if (_WIN32_WINNT >= 0x0501) || defined(_ATL_SUPPORT_VT_I8)
CComVariant(__in LONGLONG nSrc) throw()
{
vt = VT_I8;
llVal = nSrc;
}
CComVariant(__in ULONGLONG nSrc) throw()
{
vt = VT_UI8;
ullVal = nSrc;
}
#endif
In the code I tried using __int64 and LONGLONG but still I am getting the same error (0x80041005).
|
|
|
|
|
I'm thinking more of the code that implements the 'SetProperty' method
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I just figured out that this method is in a header file I took from a book.
I am debugging the code and trying to figure out the reason.
|
|
|
|
|
Got it working, 64 bit integers are handled differently from 32 bit integers.
I tweaked the code to handle 64 bit integers as well and it worked.
Thanks for your time.
|
|
|
|
|
how to get the name of propertie in actvieX control.
Eg:
"BackColor"
"Visible"
"Caption"
VIBIN
"Fool's run away,where angle's fear to tread"
|
|
|
|
|
You need to interrogate the control for its type information. This CodeProject article[^] has code that does that.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hello,
I am trying to simulate a SONY TV remote control to our Set Top box's (STB) remote control.
We use Serial Communication to communicate between the TV and the STB. We are using SONY TV RS232C Control Protocol Manual to send information thru our remote to the SONY TV.
To ensure serial communication I have used a SerialPort class of Microsoft.
Now we know interfaces as Ethernet, FireWire, and USB all that send data as a serial stream, the term "serial port" usually identifies hardware more or less compliant to the RS-232 standard, intended to interface with a modem or with a similar communication device.
But the Control Protocol doc specifies that it is RS232C complaint?
Will the same class support the serial communication?
I ask that as I feel that there is an error in the communication between my remote and the SONY TV?
|
|
|
|
|
This SerialPort[^]? Yes, it refers to the RS232C you commonly get (or used to get) on PCs.
BTW - this forum is for COM[^] programming, not COM[^] programming...
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Are you shure, that your cable has the right connections? Sometimes it is necessary to have some pins bridget inside the connectors. Is it a Control-S protocol we are talking about?
Regards: Didi
|
|
|
|
|
Can someone help with why if I can see my object in the ROT (via IROTVIEW.EXE), but when I call GetObject() it returns null.
private static Hashtable GetROT()
{
Hashtable result = new Hashtable();
IntPtr pnumFetched = IntPtr.Zero;
IRunningObjectTable runningObjectTable;
IEnumMoniker monikerEnumerator;
IMoniker[] monikers = new IMoniker[1];
Ole32.GetRunningObjectTable(0, out runningObjectTable);
runningObjectTable.EnumRunning(out monikerEnumerator);
monikerEnumerator.Reset();
while (monikerEnumerator.Next(1, monikers, pnumFetched) == 0)
{
IBindCtx ctx;
Ole32.CreateBindCtx(0, out ctx);
string runningObjectName;
monikers[0].GetDisplayName(ctx, null, out runningObjectName);
object runningObjectVal;
runningObjectTable.GetObject(monikers[0], out runningObjectVal);
System.Diagnostics.Debug.WriteLine(runningObjectName);
result[runningObjectName] = runningObjectVal;
}
return result;
}
|
|
|
|
|
What HRESULT does runningObjectTable.GetObject(monikers[0], out runningObjectVal); return? That generally sheds light on unexpected results...
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|