|
|
Thanks Sohail - an interesting article linked on your blog
seems to be exactly my problem...but I found the solution unclear.
Sounds like I need a "pre destruct" function to call in first dll, to set the smart pointers to null (as I tried, but failed to do during destruction), then call this function before 2nd calling dll starts its destruction. Only problem is, what if 1st dll destroys first, then calling it will also fail. Seems either way I might get an access violation unless I can control sequence of dll unload.
Hm, perhaps application need to call predestructor, before terminating - except then dll is destryed for other use (not an issue in my case, but not nice - althiugh I guess I am "only" clearing non-global smart pointers, so I guess that is ok...but ugly)
<br />
App >> Dll2 >> Dll1(with smartptrs)<br />
|______>Dll2.predestoy<br />
...........|___>Dll1.predestroy<br />
Any suggestions are welcome
Jens
(Sometimes I miss the old C "you allocate it, you deallocate it" days. Sure, we made mistakes, but atleast we knew what was happening.)
PS edited to get my code picture looking right, had to add "." as spaces were stripped - what kind of code view strips spaces and indentation anyway?
-- modified at 15:51 Thursday 5th January, 2006
|
|
|
|
|
Hey this is my simple soluction, can u try this and
tell me whether it is solved or not...
In the main termination of your application:-
you can do one of the following
CYourClass::ExitInstance()
{
HANDLE h1 = GetModuleHandle("dll1.dll")
HANDLE h2 = GetModuleHandle("dll2.dll")
Now you got wto handles you can free those libraries in
the order you specified as
FreeLibrary(h1);
FreeLibrary(h2);
or
FreeLibrary(h2);
FreeLibrary(h1);
}
mithun
|
|
|
|
|
That is a great idea, just what I was trying to do.
I can't believe it did not remember how to do it - I was considering writing my own callable exit functions in dlls to null the smart pointers so I would be independent of DLL unload order. I won't have a chance to try for a bit, but when I try I will post back.
Thanks Mithun
Jens
-- modified at 12:13 Friday 13th January, 2006
|
|
|
|
|
Hi ,
I have developed the com addin for outlook 2003 . I am creating the toolbar in all the folders. I am loading toolbar when we open the mail item. It's working fine loading the toolbar but when i receive the mail item with RichText format and INternationalisation option Set to Chinese Traditional Big5. When i open such mail item the toolbar doesnot loads. I am Getting problem adding the Control for editing the mail and Setting the font size. When i remove these controls the toolbar is loaded smoothly. I wam Attaching the code for your help in code snippet.
This code works but when you remove the comments for Edit This Mail and Font Size it does not wiork. I think when
the user receives the mail with RichText Format and INternation option set Chinese Traditional Big5 we dont get the
controls in standard toolbar itself , so that we cannot add those control so is there anyway to predict which type of mail is this or check if the mail is Ruch Text Edit or Internation Option Set to Chinese Traditional Big5.
// TODO: Add your implementation code here
CComQIPtr <outlook::_inspector> spInspector(OlInsp);
CComPtr <office::_commandbars> spCommandBars;
CComPtr <office::commandbar> spNewBar;
CComPtr <office::commandbar> spNewMenuBar;
CComPtr <office::commandbarcontrols> spBarControls;
CComPtr <office::commandbarcontrols> spMenuBarControls;
CComPtr <office::commandbarcontrols> spDropDownControls;
CComPtr <office::commandbarcontrols> spDropDownControls1;
CComPtr <office::commandbarcontrol> spCmdControl;
CComPtr <office::commandbarcontrol> control;
CComQIPtr <office::_commandbarbutton> spCmdButton(spCmdControl);
CComQIPtr <office::commandbarpopup> spCmdPopup(spCmdControl);
HRESULT hr;
spInspector->get_CommandBars(&spCommandBars);
spBars=spCommandBars;
hr=spCommandBars->get_Item(CComVariant(Name),&spNewBar);
if (SUCCEEDED(hr))
return hr;
IDispatch *TempItem;
CComPtr<outlook::_mailitem> CurrItem;
Outlook::OlObjectClass olmyClass;
spInspector->get_CurrentItem(&TempItem);
CurrItem=reinterpret_cast<outlook::_mailitem*>(TempItem);
hr=CurrItem->get_Class(&olmyClass);
char *str=new char[4];
itoa(olmyClass,str,5);
::MessageBox(NULL,str,"Outlook",MB_OK);
CComVariant vName(Name);
CComVariant vPos(1);
CComVariant vTemp(VARIANT_TRUE);
CComVariant vEmpty(DISP_E_PARAMNOTFOUND, VT_ERROR);
spNewBar=spCommandBars->Add(vName, vPos, vEmpty, vTemp);
spNewBar->Visible=true;
spBarControls = spNewBar->GetControls();
ATLASSERT(spBarControls);
//Declare Variant Types
CComVariant vToolBarType(1); //Simple Button
CComVariant vToolBarDropDown(10); //Drop Down Button
CComVariant vShow(VARIANT_TRUE); //True
CComVariant vType(Office::msoButtonIconAndCaption); //Style for Button
//Previous Mail
control=spCommandBars->FindControl(vToolBarType,CComVariant(359) );
CComQIPtr <office::_commandbarbutton>spCmdPrevMail(control->Copy(CComVariant(spNewBar)));
spCmdPrevMail->PutStyle(Office::msoButtonIconAndCaption);
spCmdPrevMail->Caption= "Previous Mail";
//Next Mail
control=spCommandBars->FindControl(vToolBarType,CComVariant (360));
CComQIPtr < Office::_CommandBarButton>spCmdNextMail(control->Copy(CComVariant(spNewBar)));
spCmdNextMail->PutStyle(Office::msoButtonIconAndCaption);
spCmdNextMail->PutFaceId(360);
spCmdNextMail->Caption="Next Mail";
//Edit This Mail
/* control=spCommandBars->FindControl(vEmpty,CComVariant (5604),vEmpty,vEmpty);
CComQIPtr < Office::_CommandBarButton> spCmdEditMail(control->Copy(CComVariant(spNewBar)));
spCmdEditMail->PutStyle(Office::msoButtonIconAndCaption);
spCmdEditMail->PutFaceId(31);
spCmdEditMail->Caption="Edit This Mail";
::MessageBox(NULL,"here 2","",0);
//Font Size
control=spCommandBars->FindControl(vEmpty,CComVariant (5571),vEmpty,vEmpty);
CComQIPtr < Office::_CommandBarButton> spCmdFontSize(control->Copy(CComVariant(spNewBar)));
spCmdFontSize->PutStyle(Office::msoButtonIconAndCaption);
spCmdFontSize->Caption="Font Size";
::MessageBox(NULL,"here 3","",0);
*/
//Copy
control=spBarControls->Add(CComVariant(1),CComVariant(19));
CComQIPtr < Office::_CommandBarButton> spCmdCopy(control->Move(CComVariant(spNewBar)));
spCmdCopy->PutStyle(Office::msoButtonIconAndCaption);
spCmdCopy->Caption="Copy";
spButton1->put_Tag(L"InboxLv1");
SaveCloseInbox::DispEventAdvise((IDispatch*)spButton1);
*pNewBar=spNewBar;
return S_OK;
I look forward to your reply,
Regards
Ganesh
hi
|
|
|
|
|
I have a COM inproc dll and have written a mc file containing my own custom HResults. When my component throws the HRESULT, I am checking for its value in my MFC Client by use of FormatMessage.
The HR value returned matches with the message ID but the message string comes out to a garbage value.
Has anyone written custom HRs in component and displayed the message in the MFC client before? If yes, how does it work?
Thanks for the help!
-Mandira
|
|
|
|
|
Hi,
I am trying to use Windows Media Player library "WMSServerTypeLib.dll" as an interop. I created the "WMSServerLib.dll" type library and registered using regasm.
When I try to create the object,it throws the following com exception error:
COM object with CLSID {845FB959-4279-11D2-BF23-00805FBE84A6} is either not valid or not registered.
WMSServerClass Server = new WMSServerClass();
I am able to see all the Interfaces in the object viewer
rgds
Jaffar
-- modified at 6:22 Tuesday 27th December, 2005
|
|
|
|
|
When you create an interop Dll you do not register it with regasm. An interop Dll is not a COM Dll, it is a mapping between C# and the actual COM object. You may have replaced the media player COM object with your interop Dll.
|
|
|
|
|
Hi all,
i ahve downloaded a WMI application to get WMI data from maremote computer .
i have taken a win32 console application and included a source file an dto that source file i have included the code
#include "Windows.h"
#include "comdef.h"
//#include "Wbemidl.h"
#define _WIN32_DCOM
#include <iostream>
using namespace std;
#include <comdef.h>
#include <wbemidl.h>
# pragma comment(lib, "wbemuuid.lib")
int main(int argc, char **argv)
{
HRESULT hres;
// Step 1: --------------------------------------------------
// Initialize COM. ------------------------------------------
hres = CoInitializeEx(0, COINIT_MULTITHREADED);
if (FAILED(hres))
{
cout << "Failed to initialize COM library. Error code = 0x"
<< hex << hres << endl;
return 1; // Program has failed.
}
// Step 2: --------------------------------------------------
// Set general COM security levels --------------------------
// Note: If you are using Windows 2000, you need to specify -
// the default authentication credentials for a user by using
// a SOLE_AUTHENTICATION_LIST structure in the pAuthList ----
// parameter of CoInitializeSecurity ------------------------
hres = CoInitializeSecurity(
NULL,
-1, // COM authentication
NULL, // Authentication services
NULL, // Reserved
RPC_C_AUTHN_LEVEL_DEFAULT, // Default authentication
RPC_C_IMP_LEVEL_IMPERSONATE, // Default Impersonation
NULL, // Authentication info
EOAC_NONE, // Additional capabilities
NULL // Reserved
);
if (FAILED(hres))
{
cout << "Failed to initialize security. Error code = 0x"
<< hex << hres << endl;
CoUninitialize();
return 1; // Program has failed.
}
// Step 3: ---------------------------------------------------
// Obtain the initial locator to WMI -------------------------
IWbemLocator *pLoc = NULL;
hres = CoCreateInstance(
CLSID_WbemLocator,
0,
CLSCTX_INPROC_SERVER,
IID_IWbemLocator, (LPVOID *) &pLoc);
if (FAILED(hres))
{
cout << "Failed to create IWbemLocator object."
<< " Err code = 0x"
<< hex << hres << endl;
CoUninitialize();
return 1; // Program has failed.
}
// Step 4: -----------------------------------------------------
// Connect to WMI through the IWbemLocator::ConnectServer method
IWbemServices *pSvc = NULL;
// Connect to the root\cimv2 namespace with
// the current user and obtain pointer pSvc
// to make IWbemServices calls.
hres = pLoc->ConnectServer(
_bstr_t(L"ROOT\\CIMV2"), // Object path of WMI namespace
NULL, // User name. NULL = current user
NULL, // User password. NULL = current
0, // Locale. NULL indicates current
NULL, // Security flags.
0, // Authority (e.g. Kerberos)
0, // Context object
&pSvc // pointer to IWbemServices proxy
);
if (FAILED(hres))
{
cout << "Could not connect. Error code = 0x"
<< hex << hres << endl;
pLoc->Release();
CoUninitialize();
return 1; // Program has failed.
}
cout << "Connected to ROOT\\CIMV2 WMI namespace" << endl;
// Step 5: --------------------------------------------------
// Set security levels on the proxy -------------------------
hres = CoSetProxyBlanket(
pSvc, // Indicates the proxy to set
RPC_C_AUTHN_WINNT, // RPC_C_AUTHN_xxx
RPC_C_AUTHZ_NONE, // RPC_C_AUTHZ_xxx
NULL, // Server principal name
RPC_C_AUTHN_LEVEL_CALL, // RPC_C_AUTHN_LEVEL_xxx
RPC_C_IMP_LEVEL_IMPERSONATE, // RPC_C_IMP_LEVEL_xxx
NULL, // client identity
EOAC_NONE // proxy capabilities
);
if (FAILED(hres))
{
cout << "Could not set proxy blanket. Error code = 0x"
<< hex << hres << endl;
pSvc->Release();
pLoc->Release();
CoUninitialize();
return 1; // Program has failed.
}
// Step 6: --------------------------------------------------
// Use the IWbemServices pointer to make requests of WMI ----
// For example, get the name of the operating system
IEnumWbemClassObject* pEnumerator = NULL;
hres = pSvc->ExecQuery(
bstr_t("WQL"),
bstr_t("SELECT * FROM Win32_OperatingSystem"),
WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY,
NULL,
&pEnumerator);
if (FAILED(hres))
{
cout << "Query for operating system name failed."
<< " Error code = 0x"
<< hex << hres << endl;
pSvc->Release();
pLoc->Release();
CoUninitialize();
return 1; // Program has failed.
}
// Step 7: -------------------------------------------------
// Get the data from the query in step 6 -------------------
IWbemClassObject *pclsObj;
ULONG uReturn = 0;
while (pEnumerator)
{
HRESULT hr = pEnumerator->Next(WBEM_INFINITE, 1,
&pclsObj, &uReturn);
if(0 == uReturn)
{
break;
}
VARIANT vtProp;
VariantInit(&vtProp);
// Get the value of the Name property
hr = pclsObj->Get(L"Name", 0, &vtProp, 0, 0);
wcout << " OS Name : " << vtProp.bstrVal << endl;
VariantClear(&vtProp);
}
// Cleanup
// ========
pSvc->Release();
pLoc->Release();
pEnumerator->Release();
pclsObj->Release();
CoUninitialize();
return 0; // Program successfully completed.
}
but when iam compiling iam getting the following error
fatal error C1083: Cannot open include file: 'Wbemidl.h': No such file or directory
so can u please me regarding this
abhi
|
|
|
|
|
Hi
I gave developed the com addin for outlook 2003. I am attaching toolbar in inbox second level. If the username is in Chinese Traditional Charset then it doesn't work. I mean the toolbars does not get attached.
I have written code and on reveiewing i think something goes wrong here..
CComPtr<outlook::recipient>CurrUser;
BSTR username;
char* strName=new char[50];
mysession->get_CurrentUser(&CurrUser);
CurrUser->get_Name(&username);
strcpy(strName,"\nCreated By: ");
strName=strcat(strName,_com_util::ConvertBSTRToString(username));
strcpy(m_username,strName);
delete strName;
strName=0;
...
This is not unicode strings char* and if username is Chinese Traditional charset code is imncorrect.
this coment was given by one of my senior friend.
Looking forward for reply,
Cheers
Ganesh
hi
|
|
|
|
|
Hello,
I am trying to play video inside a panel.
The problem is that i can't get a window handle for the planel and here is the code that i am wriiting:
pWindow->put_Owner (this->panel1->Handle);
[Error C2664]: 'IVideoWindow::put_Owner' : cannot convert parameter 1 from 'System::IntPtr' to 'OAHWND'
How can i fix this problem. My end goal is just to play the file in the panel not in a pop up window!!
Thanks
|
|
|
|
|
Hi,
I have to build a dll which doesn't get loaded into the process space of the client. It has to own its process space. I figured out that Out-of-proc exe is suitable option for me. But now I am bit confused about win nt services and out of proc exe.
My question is:
are both of these types compatible with all Win versions? 9x, 2k and XP?
Whats the basic difference between out of proc exe and winnt server?
Are there any address mapping issues with winnt service exes? or any other issues involved with winnt services?
Thanks a ton in advance.
Misha
|
|
|
|
|
I have written a component code ,server code and client code using c#.all the three were built successfully.but when i run the client code it throws a remoting exception "requested service cannot be found"
the server code and the client code r on the same computer.
i am new to this!!!!!! SOS
santosh
|
|
|
|
|
Dear all,
I am using EVC4 to try a ATL COM program. Some source codes are as following. I got a first-chance exception problem. Can anyone help to tell me the reason? Can we test the .dll using some tools like the ActiveX Control Test Container?
ConnectionCom.cpp
#include "stdafx.h"
#include "resource.h"
#include "initguid.h"
#include "ConnectionCom.h"
#include "ConnectionCom_i.c"
#include "Add.h"
CComModule _Module;
BEGIN_OBJECT_MAP(ObjectMap)
OBJECT_ENTRY(CLSID_Add, CAdd)
END_OBJECT_MAP()
class CConnectionComApp : public CWinApp
{
public:
virtual BOOL InitInstance();
virtual int ExitInstance();
};
CConnectionComApp theApp;
BOOL CConnectionComApp::InitInstance()
{
_Module.Init(ObjectMap, m_hInstance);
return CWinApp::InitInstance();
}
int CConnectionComApp::ExitInstance()
{
_Module.Term();
return CWinApp::ExitInstance();
}
/////////////////////////////////////////////////////////////////////////////
// Used to determine whether the DLL can be unloaded by OLE
STDAPI DllCanUnloadNow(void)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
return (AfxDllCanUnloadNow()==S_OK && _Module.GetLockCount()==0) ? S_OK : S_FALSE;
}
/////////////////////////////////////////////////////////////////////////////
// Returns a class factory to create an object of the requested type
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
{
return _Module.GetClassObject(rclsid, riid, ppv);
}
/////////////////////////////////////////////////////////////////////////////
// DllRegisterServer - Adds entries to the system registry
STDAPI DllRegisterServer(void)
{
// registers object, typelib and all interfaces in typelib
return _Module.RegisterServer(TRUE);
}
/////////////////////////////////////////////////////////////////////////////
// DllUnregisterServer - Removes entries from the system registry
STDAPI DllUnregisterServer(void)
{
_Module.UnregisterServer();
return S_OK;
}
ConnectionCom.idl:
import "oaidl.idl";
import "ocidl.idl";
[
object,
uuid(4B15EACE-A33D-4E53-B815-5486B457AEDF),
dual,
helpstring("IAdd Interface"),
pointer_default(unique)
]
interface IAdd : IDispatch
{
[id(1), helpstring("method Add")] HRESULT Add(int a, int b);
};
[
uuid(7D8286AC-AA29-48B1-A3A9-9394D54EBE22),
version(1.0),
helpstring("ConnectionCom 1.0 Type Library")
]
library CONNECTIONCOMLib
{
importlib("stdole32.tlb");
importlib("stdole2.tlb");
[
uuid(1B58E8FD-6D14-45BB-88F1-1DF5CBC05932),
helpstring("_IAddEvents Interface")
]
// dispinterface _IAddEvents
// interface _IAddEvents : IUnknown
interface _IAddEvents : IUnknown
{
[id(1), helpstring("method ExecutionOver")] HRESULT
ExecutionOver(int Result);
};
[
uuid(C0B7BD5D-B23E-4B9A-9DAE-C32B3CCEF193),
helpstring("Add Class")
]
coclass Add
{
[default] interface IAdd;
//[default, source] dispinterface _IAddEvents; take this line
//out and put the line below in
[default, source] interface _IAddEvents ;
};
};
Add.h:
#ifndef __ADD_H_
#define __ADD_H_
#include "resource.h" // main symbols
#include "ConnectionComCP.h"
/////////////////////////////////////////////////////////////////////////////
// CAdd
class ATL_NO_VTABLE CAdd :
public CComObjectRootEx<ccommultithreadmodel>,
public CComCoClass<cadd, &clsid_add="">,
public IConnectionPointContainerImpl<cadd>,
public IDispatchImpl<iadd, &iid_iadd,="" &libid_connectioncomlib="">,
public CProxy_IAddEvents< CAdd >
{
public:
CAdd()
{
}
DECLARE_REGISTRY_RESOURCEID(IDR_ADD)
DECLARE_PROTECT_FINAL_CONSTRUCT()
BEGIN_COM_MAP(CAdd)
COM_INTERFACE_ENTRY(IAdd)
COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY(IConnectionPointContainer)
COM_INTERFACE_ENTRY_IMPL(IConnectionPointContainer)
END_COM_MAP()
BEGIN_CONNECTION_POINT_MAP(CAdd)
CONNECTION_POINT_ENTRY(IID__IAddEvents)
END_CONNECTION_POINT_MAP()
// IAdd
public:
STDMETHOD(Add)(int a, int b);
};
#endif //__ADD_H_
Add.cpp
#include "stdafx.h"
#include "ConnectionCom.h"
#include "Add.h"
/////////////////////////////////////////////////////////////////////////////
// CAdd
STDMETHODIMP CAdd::Add(int a, int b)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
// TODO: Add your implementation code here
Sleep(1000);
Fire_ExecutionOver(a+b);
return S_OK;
}
When I call the Add method from the client program, I got the problem.
Please help!
Best Wishes,
HWB
|
|
|
|
|
What kind of exception was it? A first chance exception just means that the debugger is being notified before the application itself has a chance to handle the exception (the second chance) - It doesn't describe the exception itself.
Steve
|
|
|
|
|
I have an OCX Control, created with Visual C++ 6.0
I created another new OCX control, similar to the first one with very little changes. I registered the new one and it replaced the old one.
My problem is that I want both. Renaming the OCX and registering did not help me. How do i do this? Any help is highly appreciated.
Regards,
Rajesh R. Subramanian
You have an apple and me too. We exchange those and We have an apple each.
You have an idea and me too. We exchange those and We have two ideas each.
|
|
|
|
|
I dont know much about COM. Just an idea. I guess the clsid's of both are same. Try generating new CLSIDs with GUIDGEN.exe and putting them in one of the OCX. The re-build and re-register. Hope it will help
|
|
|
|
|
Exactlly, the CLSID for both the activex controls are same thats why you were
not able to use both OCX. Change the CLSID for modified OCX and register the
activex component, this would certainly solve the problem.
Cheers,
Vishal
|
|
|
|
|
You'll also want to create a new ProgID for the second component, or CreateObject()/new ActiveXObject() won't work.
Kev
|
|
|
|
|
I have a software which puts all the data in a dll....I want to access this data from MATLAB and I want it to be event driven. For this(event driven operations in MATLAB) I have to create a COM. I have no experience in creating COM. I googled but couldn;t find any good material on COM basics and hwo to create one. :(could anyone tell me how to proceed?
thanks
-- modified at 16:27 Tuesday 20th December, 2005
|
|
|
|
|
Hi Vidyarani,
I am currently working on a similar problem it seems. See the message “out-of-process DLL”. If you are trying to transfer data to MATLAB and if you are trying to let your DLL tell MATLAB what to do with the data, then you can/should use the MATLAB engine. I suppose you are writing the DLL not the application, right? There are MATLAB engine library files, which you can link with your DLL project. The MATLAB engine library basically sets up a COM connection with MATLAB with the advantage that you do not have to worry about COM.
The MATLAB engine library lets you transfer data to and from MATLAB. Your DLL should transfer data by creating MATLAB data-types (matrixes) using mx-functions, also included in the MATLAB engine library files. To create event driven operation you can first transfer data to MATLAB, and then you can execute .m-functions by letting the MATLAB engine, within your DLL, tell MATLAB which .m-function to execute. In this way, the .m-functions act as a kind of callback-functions.
I hope this is the kind of event driven operation you are after. If you also want MATLAB to call back to your DLL in an event driven manner, then you should be looking at COM as well. But to do this from within a DLL is not straightforward.
Things to look at in MATLAB help:
MATLAB \ External Interfaces/API \ Calling MATLAB from C and Fortran Programs
MATLAB \ External Interfaces/API Reference \ C Engine Functions
MATLAB \ External Interfaces/API Reference \ C MX-Functions
Things to look at in MATLAB root:
..\ MATLAB \ extern “MATLAB engine library files”
I hope this will get you going. If it doesn’t and you really want to create COM functions in your DLL and you want MATLAB to call these functions, then you are facing the same problem I have. In that case we can discuss further.
Kind regards,
Marcel Dijkstra
|
|
|
|
|
Hi Marcel,
Thanks for the reply. Let me explain as to what exactly.
---------------------------------
| Have Software which sends data |
---------------------------------
|
|
---------------------------------- --------------------------
| DLL where the data is stored | -------------|other apps accessing data|
---------------------------------- ---------------------------
whenever the DLL gets fresh data it can send a notification(or event) . I need to access this data from the DLL i.e want MATLAB to call these functions
I really dont want to make any changes to the DLL as there are a lot of other applications which use the DLL. So I will have to build a COM isn't it?
Regards,
Vidya
|
|
|
|
|
Hi Vidya,
I actually misunderstood your problem. So you are not programming the DLL, but you are thinking about making something in COM for MATLAB. Am I right in assuming that the DLL has already got a COM interface with which other programs can access its data? I assume this is the case because otherwise there would be no use in writing anything in COM if you do not want to change the DLL. How is this event/notification done? Also through COM?
Lets assume the DLL exports COM(ActiveX) automation objects then MATLAB can directly connect to these COM server objects in your DLL. Open you registry “Start-Run-regedit ” then goto ”My Computer \ HKEY_CLASSES_ROOT \ CLSID ”. Select CLSID and search for your DLL or application name. As an example search for “Microsoft Office Excel Application ”. If I do this, regedit finds the key “My Computer \ HKEY_CLASSES_ROOT \ CLSID \ {00024500-0000-0000-C000-000000000046} ”. Now you can find the subkey “ProgID ” with value “Excel.Application.11 ” or something similar.
Now you can connect to this COM server object by using its ProgID in MATLAB.
Type in the command window:
e = actxserver('Excel.Application.11');<br />
methodsview(e);<br />
e.Help();
If actxserver() succeeds you can use methodsview() to see the functions you can access. As an example we can ask the Excel COM object to display help information by calling e.Help() ;
I hope this is what you are looking for.
Regards,
Marcel
|
|
|
|
|
Hi Marcel,
The DLL has not got a COM interface. I need a COM which can speak to the DLL and MATLAB. So the COM gets the information from the DLL and sends it to MATLAB. I have an example but not able to figure out how to do it myself? So wanted to know if there are more examples?
Thanks
Vidya
|
|
|
|
|
Hi Vidya,
Correct me if m wrong !!!
Whenever the dll gets fresh data its sends some notification/events, its done?
Okay so you need to access this data, right ?
One possible way to do so is capture the notificaion/events sent by the dll.
Another way of doing such thing is use the interfaces exposed by your dll, I
mean your dll sends a notification/events, so there must exists some exposed
interfaces...
To check that your dll has exposed interfaces or not, you can design the
sample using ATL...
Steps to genertate the sample
1. Select ATL component project
2. Add simple object to project
3. Go to class view tab
3. Right click on class and select implements interface, it will pop up
a dialog
4. Click on "AddTypeLib", select your dll's typelib and click "ok"
5. It will show you the list of interfaces exposed by your dll
5. Select the appropriate interface and click ok
6. IDE will generate the source code for interface implementation
Ah, I think you should try this... this might ease the difficulty you are
facing....
Let me know if I can do ne thing?
Cheers,
Vishal
|
|
|
|
|