|
Thanks, I was hoping for more of an automated solution.
Tanks for your support
Pat O
<a href="http://currentchaos.blogspot.com/">Blog</a>
_ _ _
|
|
|
|
|
You could write a simple program to do that.
Use the ITypeLib and ITypeInfo interfaces.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Sure, that is likely what I will do, but I would rather use an existing tool if there is one.
Tanks for your support
Pat O
<a href="http://currentchaos.blogspot.com/">Blog</a>
_ _ _
|
|
|
|
|
Hi i am getting the error in subject line when trying to creat an object of a COM Component. I have registred the dll and tried but failed to go through.
Please provide the comment.
|
|
|
|
|
Have you called CoInitialize before trying to create the COM component?
«_Superman_»
|
|
|
|
|
Yes i have call CoInitialize(NULL) before calling CoCreatInstance().
Please provide comments ..
|
|
|
|
|
Hi,
I am using a VC6.0 COM component from .NET using late binding
(Createobject )
obj aa = createobject("dllname")
ret = aa.<function>(...)
The object was created and the function is executed , but on function return asp throws error as
Invalid callee. (Exception from HRESULT: 0x80020010 (DISP_E_BADCALLEE))
Please suggest me what is the cause of this error ..
vineesh
|
|
|
|
|
I'm using IXMLHTTPRequest to retrieve a XML document to parse it in an application I'm writing for a Pocket PC. I have written a function to retrieve the XML-document as a BSTR-string. Here's my function (without error handling and such):
BSTR GetXmlFeed()
{
HRESULT hr;
HRESULT hrCoInit;
hrCoInit = CoInitializeEx(NULL,COINIT_MULTITHREADED);
MSXML2::IXMLDOMDocumentPtr pXMLDoc = NULL;
MSXML2::IXMLHTTPRequestPtr pIXMLHTTPRequest = NULL;
hr=pIXMLHTTPRequest.CreateInstance("Msxml2.XMLHTTP");
hr=pIXMLHTTPRequest->open("GET", L"http://tv4vadret.se/autoflow/export/weather?cities=tv4.vader.sverige.orter.stockholm", false);
hr=pIXMLHTTPRequest->send();
pXMLDoc=pIXMLHTTPRequest->responseXML;
BSTR bstrString;
pIXMLHTTPRequest->get_responseText(&bstrString);
return bstrString;
}
This works fantastic the first time I use the function, however if I leave the program running for a while (and sees that the xml-document I'm trying to load is updated on the webserver) and call the function again, it returns with the same value of bstrString.. Can anyone please help me?
EDIT: It somehow works now, but only after my program has been idling for 5 minutes. I would like it to be able to retrieve the information straight away!
modified on Wednesday, February 18, 2009 7:32 AM
|
|
|
|
|
We have developed an ATL/COM Addin component exe for Microsoft Excel in C++ 2005 studio and sinked all the Interface events.
The Problem is that when i try to save Excel workbook 2007 it is trapping well in "WorkbookBeforeSave "Interface.. But if i try to cancel the save with condition "* pCancel=VARIANT_TRUE" still it is allowing to save the WorkSheet.
Can anyone help me on a way out how to stop saving Excel workbook sheet?
Thanks in Advance
|
|
|
|
|
Hello All,
I am tring to port my code to 64 bit machine.
I have installed XP64 bit and successfully compiled my code with x64 Active configuration in configuration settings.
I trying to get an IDispatch for a component already registred using
COleDispatchDriver::CreateDispatch(_T("ProgramID of Component"));
This code is not returning IDispatch when the code is build with x64 Active configuration in configuration settings.
But when I build code with Active Win32 configuration it works fine.
Any body knows the reason for the same?
Thanks in Advance.
|
|
|
|
|
Hi ,
I am creating a Unit Test script in CPPUnit for a new component.
I am calling CoCreateInstance ()for a component to be created , but i am getting the error in subject line.
Please provide the comments so that i can resolve the issue.
|
|
|
|
|
Since the COM component does not support aggregation, pass a NULL as the second parameter to CoCreateInstance .
«_Superman_»
|
|
|
|
|
Actually my component support aggregation , i am making unit test script using CPPUnit framwork.
HRESULT hr = CLSIDFromString( _T("{3E31EB53-8CEF-4FC9-94AC-8619887851D3}"), &clsidTemp );
hr = CoCreateInstance(clsidTemp, GetControllingUnknown() ,
CLSCTX_INPROC_SERVER, IID_IUnknown,
(void**)&m_pMessageRouter);
here i am getting error in subject line in hr..
Please provide comments.
|
|
|
|
|
//sClassName eg:ResoftSign.ResoftSignCtrl
//ResoftSign is the lib name
//ResoftSignCtrl is the class name
IDispatch* CreateClassComDispatch(BSTR sClassName)
{
CLSID clsid;
IUnknown *pUnk;
IDispatch *pDisp;
HRESULT hr;
CLSIDFromProgID(sClassName, &clsid);
hr = CoInitialize(NULL); //see here.
if(FAILED(hr))
return FALSE;
hr = CoCreateInstance(clsid,NULL,CLSCTX_ALL,IID_IUnknown,(void**)&pUnk);
if(FAILED(hr))
return FALSE;
hr = pUnk->QueryInterface(IID_IDispatch, (void **)&pDisp);
if(FAILED(hr))
{
pUnk->Release();
return FALSE;
}
return pDisp;
}
|
|
|
|
|
Hi,
I have a C++ MFC application, where I’m trying to interface with an Excel Manager application from E*TRADE through COM.
My code is:
Excel::_ApplicationPtr XL;
Excel::_WorksheetPtr pSheet;
try
{
::CoInitialize(NULL);
HRESULT hr = XL.GetActiveObject(L"Excel.Application");
pSheet = XL->ActiveSheet;
_bstr_t name = pSheet->GetName();
}
catch(_com_error &error)
{
}
I have the Excel Manager open with an active workbook and an active sheet, but the code above throws an exception, as if no sheet existed.
When I run the code, a new Excel program is shown on the task bar, next to the Excel Manager, but there’s no new EXCEL.EXE process started, so it appears that no new Excel instance is created. However, I cannot access the Excel Manager sheet through the code above. If I create a workbook and sheet in the new Excel program window, the code works correctly and shows the name of the created sheet.
How can I access the Excel Manager workbook and sheets?
|
|
|
|
|
I need to share values between two instances of a COM object.
In most of the C++ COM examples I've read, an extern UINT g_DllLockCount is declared in stdafx.h and used to maintain a count of references to the Dll. DllCanUnloadNow() then uses this to determine if the Dll can be unloaded.
I've tried adding an extern BSTR g_bString to the stdafx.h, and modifying DllCanUnloadNow() to return S_FALSE if g_bString isn't NULL .
I've added three functions to the COM Server - one to set a string value, one to retreive the string value, and one to set the value to NULL so the Dll can unload.
In my test app, I created the COM object and gave the string a value, destroyed the COM object, created another COM object, retreived the string value, then set the string to NULL so the Dll can unload. The value retreived is the initialized value of g_bString , rather than the one I set.
My questions now, are:
(1) Is what I'm trying to do even possible with COM ?
(2) Is the method outlined above correct, and it's most likely an implementation issue, or is the method itself flawed?
Any information or suggested reading ya'll can provide would be greatly appreciated.
MZR
|
|
|
|
|
you can use share memory when sharing data between EXE and COM or between COM and COM:
CreateFileMapping OpenFileMapping MapViewOfFile
|
|
|
|
|
Looks like I've got some serious reading to do...
Thanks for pointing the way, frx96!
|
|
|
|
|
Hello All,
I am trying to add a port to the windows firewall's exception list.
And I am using the INetFwProfile, INetFwOpenPort and INetFwOpenPorts COM interfaces for the purpose.
My problem is that all the required method calls on the interfaces are succeding
but without any effect, i.e. I can't see the ports in the exception list.
I am using following code sequence.
// Retrieve the collection of globally open ports.
hr = fwProfile->get_GloballyOpenPorts(&fwOpenPorts);
if (FAILED(hr))
{
printf("get_GloballyOpenPorts failed: 0x%08lx\n", hr);
goto error;
}
// Create an instance of an open port.
hr = CoCreateInstance(
__uuidof(NetFwOpenPort),
NULL,
CLSCTX_INPROC_SERVER,
__uuidof(INetFwOpenPort),
(void**)&fwOpenPort
);
if (FAILED(hr))
{
printf("CoCreateInstance failed: 0x%08lx\n", hr);
goto error;
}
// Set the port number.
hr = fwOpenPort->put_Port(portNumber);
if (FAILED(hr))
{
printf("put_Port failed: 0x%08lx\n", hr);
goto error;
}
// Set the IP protocol.
hr = fwOpenPort->put_Protocol(ipProtocol);
if (FAILED(hr))
{
printf("put_Protocol failed: 0x%08lx\n", hr);
goto error;
}
// Allocate a BSTR for the friendly name of the port.
fwBstrName = SysAllocString(name);
if (SysStringLen(fwBstrName) == 0)
{
hr = E_OUTOFMEMORY;
printf("SysAllocString failed: 0x%08lx\n", hr);
goto error;
}
// Set the friendly name of the port.
hr = fwOpenPort->put_Name(fwBstrName);
if (FAILED(hr))
{
printf("put_Name failed: 0x%08lx\n", hr);
goto error;
}
// Opens the port and adds it to the collection.
hr = fwOpenPorts->Add(fwOpenPort);
if (FAILED(hr))
{
printf("Add failed: 0x%08lx\n", hr);
goto error;
}
Please help me out...
|
|
|
|
|
hi
i have a COM definitions as
interface IMyInterface : IDispatch
{
[id(1), helpstring("method SetUserTicket")] HRESULT SetUserTicket([in] BSTR bstrTicket, [out,retval] VARIANT *varRetVal);
};
[
uuid(<some uuid="">),
version(1.0),
helpstring("My Type Library")
]
library MYLib
{
uuid(<som uuid="">),
helpstring("My Class")
coclass MyApis
{
[default] interface IMyInterface;
};
};
The output dll was formed as MY.dll
using reference add
the following line works in vb
dim aa as MYLib.MyApis
aa.SetUserTicket()
But when using CreateObject function as
CreateObject("MYLib.MyApis","") it was not working .
Is the function call is correct . or i need to pass any other names to the function.
vineesh
|
|
|
|
|
Did you create all the registry entries for your COM Server? When you add a reference to the .dll, VB reads the .dll and accesses it directly. When you use CreateObject(ObjectID) , COM looks up the ObjectID in the registry to get its GUID and then looks up the GUID in the registry to find your .dll and its type library.
To be able to use CreateObject() , there are several registry entries needed. Your library is MY.dll, so let's call the typelib MY.tlb. These are the minimum entries you need:
HKEY_CLASSES_ROOT\\MYLib.MyApis = "My COM Server" (Friendly name)<br />
HKEY_CLASSES_ROOT\\MYLib.MyApis\\CLSID = GUID_of_Class_MyApis<br />
<br />
HKEY_CLASSES_ROOT\\CLSID\\GUID_of_Class_MyApis = "My COM Server" (Friendly name)<br />
HKEY_CLASSES_ROOT\\CLSID\\GUID_of_Class_MyApis\\InProcServer32 = "[PATH]\MY.dll"<br />
ThreadingModel = "Apartment" (This one is a value under InProcServer32, not a key)<br />
HKEY_CLASSES_ROOT\\CLSID\\GUID_of_Class_MyApis\\ProgID = "MYLib.MyApis"<br />
HKEY_CLASSES_ROOT\\CLSID\\GUID_of_Class_MyApis\\TypeLib = GUID_of_TypeLib<br />
HKEY_CLASSES_ROOT\\CLSID\\GUID_of_Class_MyApis\\Version = "1.0"<br />
<br />
HKEY_CLASSES_ROOT\\Interface\\GUID_of_Interface_IMyInterface = "My COM Interface" (Friendly name)<br />
HKEY_CLASSES_ROOT\\Interface\\GUID_of_Interface_IMyInterface\\TypeLib = GUID_of_TypeLib<br />
HKEY_CLASSES_ROOT\\Interface\\GUID_of_Interface_IMyInterface\\Version = "1.0"<br />
<br />
HKEY_CLASSES_ROOT\\TypeLib\\GUID_of_TypeLib <br />
HKEY_CLASSES_ROOT\\TypeLib\\GUID_of_TypeLib\\1.0 = "My COM Server Type Library" (Friendly name)<br />
HKEY_CLASSES_ROOT\\TypeLib\\GUID_of_TypeLib\\1.0\\0<br />
HKEY_CLASSES_ROOT\\TypeLib\\GUID_of_TypeLib\\1.0\\0\\win32 = "[PATH]\MY.tlb"<br />
Technically there is a versioning issue here, so your \\GUID_of_Class_MyApis\\ProgID value should be "MYLib.MyApis.1" and then you'd create a VersionIndependentID key to associate "MYLib.MyApis" with "MYLib.MyApis.1"... but this isn't strictly necessary.
Though you can create them by hand using RegEdit, all of these keys should be created in your DLL's DllRegisterServer() method and they should be deleted in your DLL's DllUnregisterServer() method, for use with RegSvr32.exe
Hope this helps,
MZR
|
|
|
|
|
Hi all,
I used the application downloadable fron this website and I tested it using 3 scanners.
I have a problem only with ones: a Kodak ds3500
I installed the twain toolkit in order to verify the twain functionalities of this scanner and its behavior is good!
The scanner doesn't work only with "our" application!!!
Can anyone explain me the reason about this problem?????
Thank you very much in advance
Rob
|
|
|
|
|
Hi,
I need to un register/delete the existing dlls in COM+ and re register with the updated dlls. Could some one help me with how do I do it from the command line? We do not have test server to play around with it and be able to get it right with couple of trails. I will have to do on the production directly so please help me with the right syntax say for a Test.dll.
Thanks in advance.
-L
|
|
|
|
|
Hi,
I tried using regsvr32 <filename> to register and regsvr32 -u <filename> to un register. I did this on my Dev PC in command prompt by creating a brand new COM+ application in component services. I got the proper messages in a message box and I thought it was successful but when I looked under the COM+ I do not see those components installed. Am I missing some thing here?
Thanks,
-L
|
|
|
|
|
It depends.
I'm assuming that when you say "I looked under the COM+" you are trying to add a reference in some MS environment, and are selecting the COM+ tab in that dialog box.
RegSvr32 test.dll calls the DllRegisterServer() method within the DLL.
RegSvr32 -u test.dll calls the DllUnregisterServer() method within the DLL.
Unless these two methods return an error, you will get the "Succeeded" message, even if these are empty functions that just return S_OK . It doesn't matter, as far as RegSvr32 is concerned, if the DLL is (un)registered properly or not, so long as S_OK is returned.
Check your DllRegisterServer and DllUnregisterServer methods and make sure the registry keys are being created/deleted properly.
MZR
|
|
|
|