|
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
|
|
|
|
|
hi experts,
I hav create a COM DLL using VC++6.0 application.which has a function :
[id(13), helpstring("method LngGenSuggW")] HRESULT LngGenSuggW([in]BSTR pwIpIscii,[out]VARIANT *pawSuggArray);
and my client application is in C# 2005.
which is as follows:
COM_INSPELLLib.ComInSpell objCom = new COM_INSPELLLib.ComInSpell();
String sIpWord;
object sSuggArray = new object() ;
objCom.LngGenSuggW( sIpWord, out sSuggArray);
and I got the sSuggArray with the answer return by COM DLL.
which contains "3 strings" means string array.
but the problem is object does not contain any method to get these string back.
Is there any method or solution??
that converts or parse this object array sSuggArray into String array and
so that I can use it for further procedure.
please help me..
I try it.. but cant done..
waiting for ur valuable reply..
thanx & regards,
Victory.
|
|
|
|
|
If you know you're going to return 3 strings, why not just return an array of BSTRs, instead of VARIANT ?
|
|
|
|
|
1.Modify like this:
[out] BSTR* pawSuggArray
2.
"SAFEARRAY" maybe also can do this.
|
|
|
|
|
Hi can somebody help me out on how I would be able to sniff data from a com port that is already opened by another application?I really need this asap. If you know how please help me.
|
|
|
|
|
rj_21_2003 wrote: I really need this asap.
This statement won't help you in any way. Rather the opposite.
rj_21_2003 wrote: com port
This forum is about Component Object Model, not communication ports.
rj_21_2003 wrote: I would be able to sniff data from a com port that is already opened by another application
Have a look at PortMon written by Mark Russinovich here[^].
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Hi Friends.
I have create Outlook addin that save and update contact from my client website. i Save the ContactId of the Client Contact in "CustomerID" field of outlook and it work fine. but when my client test it on his machine it give error Property "CustomerID" unkown. My Client outlook Language is Spanish. Plz help me
WANTED wasim khan(Killed 50 Innocent Buggs, Distroyed 200 Exception, make 5 Project Hostage) any Compnay Hire him will pay 30,000. Best place where u can get him is Sorcim Technologies Murre Road RWP
|
|
|
|
|
Hi,
I am using the ATL COM DLL. In this I am createng two threads.
I have added new ATL object which supports connceting point, appartment thereaded model,
Dual interface and agregation=yes. While creating thread and passing the interface pointer as this pointer.
hStatusThread = CreateThread(NULL,
o,
LPTHREAD_START_ROUTINE(StatusThread),
(LPVOID)this,
0,
&dwThStId);
::SetThreadPriority(hStatusThread, THREAD_PRIORITY_HIGHEST);
I am accessing the interface pointer in thread and firing the event..
UINT StatusThread(LPVOID param)
{
CMyConnectObj *ptrObj = NULL;
ptrObj = (CMyConnectObj*)param;
if(ptrObj == NULL)
return 0;
if(WaitForSingleObject(g_Mutex,INFINITE) == WAIT_OBJECT_0)
{
ptrObj->Fire_ErrorCode(lErrorCode);
ReleaseMutex(g_Mutex);
}
}
I am using vb6.0 client to use this dll.
but while firing event at line i
ptrObj->Fire_ErrorCode(lErrorCode);
it's giving error as "Unhandled Exception in ConnectProg.exe (MSVBVM60.dll)0x0000005: Access Violation.
But if I tried to fire event for one of the ATL object function there is no problem at all.
Please help me for this with perect solution..
It's very urgent.
|
|
|
|
|
chetanjoshi9 wrote: But if I tried to fire event for one of the ATL object function there is no problem at all.
This is due to the fact that you have not initialized COM for your new apartment, i.e. in your worker thread. You have to call ::CoInitialize() before using any COM functionality from your worker thread. Don't forget to place a matching call to ::CoUninitialize() before exiting your worker thread.
When you've done that you will hit another problem since you're trying to call the interface to the client's event sink from another apartment than it belongs to.
You have to marshal the events sink interface to the apartment of your worker thread.
Have a look at Michael Lindig's solution for that here[^].
It uses the GIT (Global Interface Table) for that and you'll be able to fire your events from any apartment.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
In order to login SSL website ,the client must be choose the certificate in the local machine .I want to know whether certificate can be chose by BHO (Bowser helper object).
I know BHO can make IE GoBack ,GoForward and navigate and so on. And if so , how to make it ?
Thank you very much!
Lampa
|
|
|
|
|
i need anyone who can teach me how to write codes to solve the problem of time-tabling schedule using simulated annealing technique. i will appreciate it if the program can be written with MATLAB language.
awoyale
|
|
|
|
|
Hi,
Quite new to COM, I need to reuse VB runtime into ASP.NET C#
I was able to give reference to the same and now am able to create objects of type PropertyBagClass in my code behind.
Question : Whenever PropertBagClass.ReadProperty() method returns a null value, it give an object of type System.__ComObject. I can see it in Quick Watch window. I need to check whether the returned object is null. How can it be done ? There is a default value in case the property does not exists in PropertyBagClass, but it does not return the default value.
Please let me know some pointers about solving this issue.
Thanks !
"A good programmer is someone who looks both ways before crossing a one-way street." -- Doug Linder
coolestCoder
|
|
|
|
|
Hi,
I would like to get control on menus of Office 2007 but I am not able to find out what type of interface is used to control this. Is there any way to get the control on these.
THanks
SNI
|
|
|
|
|