|
Hi,
I´ve tried the adConnectUnspecified but I´m still getting the same error.
I´m using the following string to connect the DB:
static char CnnStr[200]="Provider=sqloledb;Data Source=SAUCE; \
Initial Catalog=loadDB; \
User Id=admin;Password=admin;";
in the:
dbConn->Open("admin","admin",CnnStr)
I´m using the sample in http://www.codeguru.com/cpp/data/mfc_database/ado/article.php/c6729/
to build my service. In fact that example worked ok as an executable, but then when I tried to run it in a Windows Service I began to receive this "access violation" messages. Then I create it dynamicaly (dbConn=new ADOConnect()) , ´cause I thought that these was the problem, but the problem persists.
Thanks,
Dyrl
|
|
|
|
|
Hmmm.
Well, firstly, if you have the username and password in your connection string, you don't need them in the Open function, you can leave them both as "" there.
Secondly, are you initialising the Com interface? You need to run
::CoInitialize(NULL);
before running any ADO code in C++ - I had this problem for a long time when I was first learning! If you don't use this line you will get a pretty serious error - i.e. it won't work!
|
|
|
|
|
Hello,
I was wondering how to build an ActiveX control that integrates as a component "off the form" (say when using VB.net '03 or VB.NET '05). This is a component that has no user interface (except perhaps an icon) and needs never to be visible. I tried all of the various flags in the DECLARE_VIEWSTATUS macro to no avail. For example, the timer object in VB.NET is never on the form; it is shown as a component below the form.
I have experience with COM and ActiveX; I just do not know how to make my component behave like the 'timer' component.
Thanks in advance,
Dave.
|
|
|
|
|
Hi
I want to include an xml validation schema as a part of an executable. My problem is how to add the schema to the MSXML2::XMLSchemaCache40. I have a schema called 'setup.xsd', and m_schemaCache is a MSXML2::IXMLDOMSchemaCollection2 interface to XMLSchemaCache40.
The following code works ('setup' is the namespace for the schema).
<br />
hr = m_schemaCache->add(L"setup", L"Setup.xsd");<br />
Now I want to load the schema from a resource. Since IXMLDOMSchemaCollection2::add only accepts url's or MSXML2::DOMDocument's, I decided to parse the xml data using DOMDocument, and then pass the DOMDocument over to the XMLSchemaCache40.
In the following code, everything seems to be ok until I try to add the DOMDocument to the XMLSchemaCache40. The resource is loaded, The DOMDocument parses it, and no errors are found. The readyState of the DOMDocument is 4.
<br />
wchar_t sResName[10];<br />
swprintf_s(sResName, 10, L"#%d", resourceId);<br />
<br />
TCHAR sRestype[13] = _T("SCHEMA");<br />
HRSRC hres = FindResource(NULL, sResName, sRestype);<br />
if (hres == 0) { <br />
return false;<br />
}<br />
<br />
HGLOBAL hbytes = LoadResource(NULL, hres);<br />
<br />
LPVOID pdata = LockResource(hbytes);<br />
<br />
LPBYTE sData = (LPBYTE)pdata;<br />
BSTR sXml = _bstr_t((char*) sData); <br />
<br />
MSXML2::IXMLDOMDocument* doc;<br />
hr = CoCreateInstance(__uuidof(MSXML2::DOMDocument), NULL, CLSCTX_ALL,<br />
__uuidof(MSXML2::IXMLDOMDocument), (void**) &doc);<br />
if (FAILED(hr))<br />
return false;<br />
<br />
doc->put_async(VARIANT_FALSE);<br />
doc->put_validateOnParse(VARIANT_TRUE);<br />
<br />
VARIANT_BOOL succeeded;<br />
hr = doc->loadXML(sXml, &succeeded);<br />
if (succeeded != VARIANT_TRUE) {<br />
return false;<br />
} <br />
<br />
hr = m_schemaCache->add(bstrNamespace, _variant_t(doc));<br />
if ( FAILED(hr) )<br />
return false;<br />
<br />
return true;<br />
What am I doing wrong? Thanks in advance for any answers
øivind
|
|
|
|
|
how do i protect an activex not to replace?
|
|
|
|
|
<br />
ICreateDevEnun *pSysDevEnum<br />
IEnumMoniker *pEnumCat;<br />
IMoniker *pMoniker;<br />
IPropertyBag2 *pPropBag2;<br />
ULONG cFetched;<br />
hr = CoCreateInstance(CLSID_SystemDevEnum, NULL, CLSCTX_INPROC_SERVER,<br />
IID_ICreateDevEnum, (void**)(&pSysDevEnum));<br />
hr = pSysDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory,<br />
&pEnumCat, 0);<br />
while(pEnumCat->Next(1, &pMoniker, &cFetched) == S_OK){<br />
hr = pMoniker->BindToStorage(0,0,IID_IPropertyBag2,(void**)pPropBag2);<br />
<br />
The above code produced FAILED(hr)== true at BindToStorage. But it succeeded if IPropertyBag was used instead
What could be the reason?
|
|
|
|
|
The moniker from a device is not a file-moniker. so you can't bind it to a storage. look at IMoniker in your SDK help.
|
|
|
|
|
hi all
iam working on WMI . iam trying to write an application for Event notification.
Iam usimg Win32_Process class, and ExecNotificationQuery for WQl query.
Iam trying to display a message when a new process is created.
my WQL query is
hres = pSvc->ExecNotificationQuery(
bstr_t("WQL"),
bstr_t("SELECT * FROM __InstanceCreationEvent WITHIN 5 WHERE TargetInstance ISA 'Win32_Process' And (TargetInstance.Name = 'notepad.exe' OR TargetInstance.Name = 'calc.exe' ) "),
WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY,
NULL,
&pEnumerator);
if iam not wrong ,After executing this query TargetInstance will be Instance of WIn32_process class.
and now iam trying extract data usoing this statement
hr = pclsObj->Get(L("TargetInstance.Name"), 0, &vtProp, 0, 0);
but iam not able to get value of Name property of Win32_Process class into vtProp where vtProp is of type VARIANT.
IWbemClassObject->Get( LPCWSTR wszName,LONG lFlags, VARIANT* pVal,CIMTYPE* pvtType, LONG* plFlavor) is used to retrieves Specified property value.
but here iam using it for getting value fron an istance i.e TargetInstance.Name. Is it the correct way to do if not please help me in extracting value of Name Property.
Please help me in solving this .
Thanks in advance
abhi
|
|
|
|
|
abhiramsss wrote: hr = pclsObj->Get(L("TargetInstance.Name"), 0, &vtProp, 0, 0);
I doubt you can get the TargetInstance.Name this way. I'd Get the TargetInstance, put that into a IWbemClassObject, then call Get again to retrieve the Name property of TargetInstance.
|
|
|
|
|
I want to display a message when a process is closed can u please advice me regarding this.
Thanks in Advance
abhi
|
|
|
|
|
Once you've got the ProcessID, open up a handle to it and wait on it. I *think* you can get the process handle directly by Win32_Process::Handle, but in case you can't OpenProcess/WaitForSingleObject will work.
|
|
|
|
|
Hi
iam working on WMI(windows MAnagement Instrumentation). i have created a sample application using WIn32_process class . iam able to display messages when an Process is opened or closed.
now what i want to do is to create an object and then register a call back function . This class also take process names through another method . this class should call the above callbackfunction when one of the process(taken through the above method) is either started or exited.
can you please suggest me how to procedd with this task.
Thanks in advance
abhi
|
|
|
|
|
HI
i want to create a wrapper class of win32_Process class and i want to define my own methods into that wrapper class and after that i want to display messages whenever a new process is started or class using that wrapper class .
Can you please suggest how to procedd with this
Thanks in Advance
abhi
|
|
|
|
|
Can u please suggest me how to write call back function for Event notification whenever a new process is executed using WMI
Thanks
Abhi
abhi
|
|
|
|
|
Let's start off with a little modification of your original code. Use this WMI query instead, "Select * From Win32_ProcessStartTrace" to get notified of process creation.
Now to receive notification whenever a new Win32_ProcessStartTrace is fired, you need to invoke that WMI query with ExecNotificationQueryAsync. This operates almost exactly like ExecNotificationQuery, except it takes one extra parameter: a pointer to your implementation of IWbemObjectSink.
If you don't have an implementation of IWbemObjectSink, just use the stock implementation from MSDN[^] or Codeproject[^].
But why do you need to be notified when a new process is being created? What are you going to do to the process?
|
|
|
|
|
thanks for your suggestion i will try to implement it.
actually iam working on a network.
so now i want to display messages remotely . Saty there aretwo machines A and B so whenever a exe is executed on machine B it should display message on machine A,
so please suggest me how to work remotely using WMI.
Thanks in Advance
abhi
abhi
|
|
|
|
|
I thought Windows already provided this functionality via the Event logs.
System Policy editor (gpedit.msc) -> Computer Configuration -> Windows Settings -> Security Settings -> Local Policies -> Audit Policy -> Audit process tracking (audit success).
Unfortunately, this option also audits a heap of other events, in addition to process startup/shutdown.
|
|
|
|
|
Hi,
Can u please suggest me how to get WMI data from a remote computer
Can u please suggest me the changes i have to do in Connectserver Function and the required DCOM settings required to access data remotely.
Thank you
Abhi
abhi
|
|
|
|
|
hi
iam trying to access remote data using the following arguments in ConnectServer
hres = pLoc->ConnectServer(
_bstr_t(L"\\\\test\\root\\cimv2"),
_bstr_t(L"kumar"), // User name
_bstr_t(L"Keta001"), // User password
_bstr_t(L"MS_409"), // Locale
NULL, // Security flags
_bstr_t(L"CRAFT"), // Authority
0, // Context object
&pSvc // IWbemServices proxy
);
where test is the name of testPC
kumar is the username of remote PC
Keta001 is the password
CRAFT is the domain name
but when iam running my application iam getting error
cannot be connected error code 80041008
can u please suggest how to solve this.
Thanks In Advance
abhi
|
|
|
|
|
hi when iam tryig to acquire UPS data using WIN32_UninterruptiblePowerSupply class of WMI ,iam not able to get the output,and i have searched on net for the solution , what i found is
Most UPS's now days disable native OS support when they install, because
they want to use their agent program instead. A good example is APC. So if
your using an APC by default it turns off UPS support (Maybe MS needs to
beef up the UPS support so APC doesnt feel they need to do this for
functionality). So in this case WMI wont be any help. But IF your UPS uses
the built in UPS support Windows provides then you should be ok
can u please elaborate on this and tell me how to get UPS data.
Thanks in Advance
abhi
|
|
|
|
|
Hi iam working on winows 2003 clustering and i have to use WMI.
can u please help me with waht all we can do with WMI wrt to clustering
and can i have sample scripts
Thanks in advance
abhi
|
|
|
|
|
Hi all,
I would like to ask if anybody is knowledgeable in service objects? Can anyone recommend a site or provide me with documentation for me to understand more about service and control objects?
Thanks a lot,
waxie
|
|
|
|
|
Hi,
Can I write a shell extension which can process my own shell format?
For example: I have an application which has own data format, and when
drag from this applicaion and drop on explorer, the extension can process this data format.
It's like when you drag some texts and drop on explorer, which generate some special file.
Of course, I want generate my own files.
Anyone can help me?
|
|
|
|
|
hi
I am not sure but have look at RegisterShellFileTypes()
"Every morning I go through Forbes list of 40 richest people in the world. If my name is not in there, I go to work..!!!"
|
|
|
|
|
The most common format for the explorer is the combination of RegisterClipboardFormat(CFSTR_FILECONTENTS) and RegisterClipboardFormat(CFSTR_FILEDESCRIPTOR). These formats tells the explorer what filename to use and to render data from a storage (IStream). The IStream can render any data-format you want. For small data you can also use a HGLOBAL memory block to render your data-format.
To realize this - you have to implement your own IDataObject at least.
|
|
|
|