|
Hi,
I am new to this COM thing..but let me see if i got u right. COM aggregation is a method by which v can encapsulate a inner COM componet within another and the client can call the interfacing methods of the outer component instead of the inner COM.
So, How will this solve my issue?? Actually what i need is 2 clients accessing the same COM component instance..how v can get this??Plz explain.
Thanks.
Regards,
Priya.
|
|
|
|
|
shivapriyak wrote: So, How will this solve my issue?? Actually what i need is 2 clients accessing the same COM component instance.
Ok, I misunderstood your problem.
Then I suggest you do what Tim suggested: create an exe-server and register the instance in the Running-Object-Table (ROT). Clients to the server can then request an already running instance of the server from the ROT. If it's essential that there is only one single instance running at the same time you can implement it as a singleton.
Perhaps this[^] article can help you. It's partly written in C#, but the concept is the same no matter the language.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Hi,
I went thru the article.
What i understood is that the COM has to be registered and running in the ROT table. Then both the clients can access the same running instance of the COM dll by getting pointers to it.Correct me if i am wrong...
But i am afraid i don't know C# can u tell me how to do this in vb??
both my clients r vb applic only..
Thanks
Priya
|
|
|
|
|
shivapriyak wrote: What i understood is that the COM has to be registered and running in the ROT table. Then both the clients can access the same running instance of the COM dll by getting pointers to it.Correct me if i am wrong...
No need for correction, you've got it.
shivapriyak wrote: i don't know C# can u tell me how to do this in vb?
Sorry mate, unfortunately I don't know how the synthax looks in VB for doing COM.
However, it's the flow that's important; in what order to do things and what IRunningObjectTable methods to call since it will be the same regardless of the language used. You'll have to translate it to VB by yourself.
In addition to the links that Tim provided you with, have a look at this[^], an article in MS Systems Journal written by Jeff Prosise about the use of ROT and monikers.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Hi,
Thnx everybody I could solve this issue.
|
|
|
|
|
Hi,
i have an com application which keeps track of another application and displays the message accordingly.
but it gives error70 when we handle the application to and fro very frequently.
can anyone help me on Error-70 or any idea about the possible reasons.
thanks in advance
amolk
|
|
|
|
|
Hai friends,
I am get an error "The stub received bad data" while calling CreateInstance function.
But some times its working.
I am using a COM Exe as server. I am using a regular dll to call the interface functions of COM Server. I am getting this error in dll.I had registered the COM Exe using regerver.
OS installed : WindowsXP Service Pack 2
Platform : VC++6.0 Service Pack 6
Can anybody help me to solve?
With regards,
appoos
Known is a drop, unknown is an ocean
|
|
|
|
|
Hello,
1. Have you initialized all your variables inside com server? Some memory garbage can cause the problem
2. It can be some timing problem with initialization. Try to play with some delays (just use Sleep(…)) inside constructor and FinalConstruct() method of your exe com server.
Regards,
|
|
|
|
|
i have made the plugin in VC for outlook so when i send mail the micorsoft word page remain open i want to close that page so any1 can help me in this regard.
the code for initilizing the word is as follow
if(EditorType==olEditorWord)
{
HWND hwnd;
hwnd = ::GetForegroundWindow();
HRESULT hr = EnumChildWindows(hwnd, &EnumWindowsProc, NULL);
CComPtr<idispatch>Dispatch;
spInspect->get_WordEditor((IDispatch**)&Dispatch);
DISPID dispp;
OLECHAR FAR* szMemberpName;
EXCEPINFO pexcep;
UINT uArgErr;
DISPPARAMS disparams={NULL,NULL,0,0};
szMemberpName = L"Close";
VARIANTARG ApResult;
Dispatch->GetIDsOfNames (IID_NULL, &szMemberpName, 1, LOCALE_SYSTEM_DEFAULT, &dispp);
hr = Dispatch->Invoke(dispp, IID_NULL, LOCALE_SYSTEM_DEFAULT,DISPATCH_METHOD, &disparams, &ApResult, &pexcep, &uArgErr);
if(FAILED(hr))
{
_bstr_t des;
char * ii;
des = pexcep.bstrDescription;
ii = (char*) des;
}
else
{}
|
|
|
|
|
Hi all ,
How can I get the path of a COM DLL ??
I am using this way..
Inside DLL , I am writing this code.
/******************************************************/
HINSTANCE g_hInst;
TCHAR szModule[MAX_PATH];
g_hInst = _Module.GetModuleInstance();
GetModuleFileName(g_hInst, szModule, MAX_PATH);
/*******************************************************/
I am getting the Path . But am getting in this form..
"D:\THINVI~1\INTEGR~1.DLL" .
The tilt sign makes the folder and file names incomplete . My actual path is
"D:\THINVISITS_14-2-07\INTEGRALHOTBAR.DLL"
So how can I get my dll path in the complete form without Tilt(~)..
Please Help Me
Thanks
George.
|
|
|
|
|
Add an additional call to GetLongPathName .
Steve
|
|
|
|
|
Hi all,
I have a VB applicatiOn , which calls a function in VC++ DLL.
Arguement of function is a one dimensional string array.
Array will get filled in VC++ dll function.
I have written the programme given below.
But I am unable to get the array elements from VC++.
Programme is given below.
VC++ COM
/*****************************************/
STDMETHODIMP CTest111CL::myFun(SAFEARRAY **ppOutputArray)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
HRESULT hresult;
SAFEARRAYBOUND aDim[1] ;
aDim[0].lLbound = 0;
aDim[0].cElements = 3;
BSTR HUGEP *pbstr;
*ppOutputArray = SafeArrayCreate(VT_BSTR , 1, aDim);
hresult=SafeArrayAccessData(*ppOutputArray,(void HUGEP**)&pbstr);
pbstr[0] = SysAllocString(OLESTR("SOURCE_VA"));
pbstr[1] = SysAllocString(OLESTR("ACV"));
pbstr[2] = SysAllocString(OLESTR("10"));
SafeArrayUnaccessData(*ppOutputArray);
return S_OK;
}
/**********************************************/
VB Application
---------------
''''''''''''''''''''''''''''
Dim i As Test111CL
Private Sub Command1_Click()
Dim arr_str(3) As String
Set i = New Test111CL
i.myFun arr_str()
MsgBox arr_str(1)
End Sub
''''''''''''''''''''''''''
MsgBox arr_str(1) , The message Box shows and empty string.
How can I rectify it. Please help me.
Thanks
George
-- modified at 4:53 Friday 9th February, 2007
|
|
|
|
|
Hello,
Try this:
Idl: HRESULT FunName([in,out] SAFEARRAY(BSTR)* pbsData);
.h: STDMETHOD(FunName)((SAFEARRAY** pbsData);
.cpp: STDMETHODIMP ClassName:: FunName(SAFEARRAY** pbsData)
{
//checking if it is an one-dimensional array
if((*pbsData)->cDims != 1)
return E_FAIL;
//Checking the number of elements of the array
if(3 != (*pbsData)->rgsabound[0].cElements)
return E_FAIL;
// locking the array before using its elements
HRESULT hr = SafeArrayLock(*pbsData);
if(FAILED(hr))
return E_FAIL;
// using the array
BSTR* pbs = (BSTR*)(*pbsData)->pvData;
pbs[0] = …
pbs[1] = …
pbs[2] = …
…
// releasing the array
return SafeArrayUnlock(*pbsData);
}
VB: Option Explicit
Option Base 1
Dim sArr(1 To 3) As String
Call ….FunName(sArr)
Regards,
|
|
|
|
|
Hi lafleon ,
Its working excellent . I have implemented it for a 3d array and got correct result.
Thank you Very much for your help.
George
|
|
|
|
|
Hello,
Read the article on MSDN: “How to Pass Arrays between Visual Basic and C”. http://support.microsoft.com/kb/207931
Regards
|
|
|
|
|
Some more links:
1. "Passing an array from VC++ DLL to VB", by Amol Kakhandki on Code project. http://www.codeproject.com/dll/ctovbarray_passing.asp
2. http://www.manbu.net/Lib/En/Class5/Sub7/1/23.asp
|
|
|
|
|
Hi All,
I want to enumerate menu item identifiers of MS-Office apps. I found all MS-Office apps share resources stroed in some dll (MSO.dll, may be wrong). I like to disable some menu items by using subclassing or something else. So can anybody help to enumerate these id's.
Thanks a lot!
- Santosh
-- modified at 4:14 Friday 9th February, 2007
|
|
|
|
|
Hi all,
I have code for passing 2d array from VC++ to VB6(Code is given below), But My need is to pass a 3d array from VC++ to VB6, Can any one pleas replace the code I have given for 2d to 3d
STDMETHODIMP TestMacroInterface::ProcessStringArray(SAFEARRAY**ppOutputArray)
{
HRESULT hresult;
SAFEARRAYBOUND aDim[2]
aDim[0].lLbound = 0;
aDim[0].cElements = 3;
aDim[1].lLbound = 0;
aDim[1].cElements = 2
BSTR HUGEP *pbstr;
*ppOutputArray=SafeArrayCreate(VT_BSTR , 2, aDim);
if (*ppOutputArray==NULL)
{
::MessageBox(NULL, _T("NOT_OK"), _T("Pickup"), MB_OK);
}
else
hresult=SafeArrayAccessData(*ppOutputArray,(void HUGEP**)&pbstr)
pbstr[0][0] = SysAllocString(OLESTR("SOURCE_VA"));
pbstr[0][1] = SysAllocString(OLESTR("ACV"));
pbstr[0][2] = SysAllocString(OLESTR("10"));
SafeArrayUnaccessData(*ppOutputArray);
}
Thanks
George
|
|
|
|
|
georgekjolly wrote: SAFEARRAYBOUND aDim[2]
aDim[0].lLbound = 0;
aDim[0].cElements = 3;
aDim[1].lLbound = 0;
aDim[1].cElements = 2
BSTR HUGEP *pbstr;
*ppOutputArray=SafeArrayCreate(VT_BSTR , 2, aDim);
if (*ppOutputArray==NULL)
{
::MessageBox(NULL, _T("NOT_OK"), _T("Pickup"), MB_OK);
}
Change this to,
SAFEARRAYBOUND aDim[3]
aDim[0].lLbound = 0;
aDim[0].cElements = 3;
aDim[1].lLbound = 0;
aDim[1].cElements = 3
aDim[2].lLbound = 0;
aDim[2].cElements = 3
BSTR HUGEP *pbstr;
*ppOutputArray=SafeArrayCreate(VT_BSTR , 3, aDim);
if (*ppOutputArray==NULL)
{
|
|
|
|
|
Hi Prasad,
Thank you very much.
And some more help please ..
1-> How can I pass a 3d array from VB to VC++ ( Just code )
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim i As Test33CL
Dim iArray(1 To 3, 1 To 3, 1 To 3) As String
Private Sub Command1_Click()
Set i = New Test33CL
i.StringFun (iArray)
End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Is there is a riht way , I am getting error.
2-> how to assign string value to BSTR *pbstr.
Thanks
George
|
|
|
|
|
Hi George,
I'm not VB guy. Lets wait some body to solve your query.
|
|
|
|
|
Hai Prasad,
Sorry for again disturbing u .. It is an assignment for me from a company ,If I am clearing this I will get Job there...
Please Just See my assignment of String to the 3d array is in Right way ,Programme I have given below..
STDMETHODIMP CTestMacroInterface::ProcessStringArray(SAFEARRAY *ppOutputArray)
{
SAFEARRAYBOUND aDim[3]
aDim[0].lLbound = 0;
aDim[0].cElements = 3;
aDim[1].lLbound = 0;
aDim[1].cElements = 3
aDim[2].lLbound = 0;
aDim[2].cElements = 3
HRESULT hr;
BSTR HUGEP *pbstr;
*ppOutputArray=SafeArrayCreate(VT_BSTR , 3, aDim);
if (*ppOutputArray==NULL)
{
Messagebox("Null");
}
else
hr=SafeArrayAccessData(*ppOutputArray,(void HUGEP**)&pbstr
/*******************************************************************
Now I need to store my data 3 dimensionaly data is
FirstName LastName Job
Ram Lakhan Engineer
Dipu Das Merchant
Vinu Lal Bussiness
a[0][0] = "Ram" , a[0][1] = "Lakhan" , a[0][2] = "Engineer"
a[1][0] = "Dipu" , a[1][1] = "Das" , a[1][2] = "Merchant"
a[2][0] = "Vinu" , a[2][1] = "Lal" , a[2][2] = "Bussiness"
**************************************************************/
// Here I have assigned my values, Is this the correct way of assigning values ??
pbstr[0] = SysAllocString(OLESTR("Ram")); // for a[0][0]
pbstr[1] = SysAllocString(OLESTR("Dipu")); // for a[1][0]
pbstr[2] = SysAllocString(OLESTR("Vinu")); // for a[2][0]
pbstr[3] = SysAllocString(OLESTR("Lakhan")); // for a[0][1]
pbstr[4] = SysAllocString(OLESTR("Das")); // for a[1][1]
pbstr[5] = SysAllocString(OLESTR("Lal")); // for a[2][1]
pbstr[6] = SysAllocString(OLESTR("Engineer")); // for a[0][2]
pbstr[7] = SysAllocString(OLESTR("Merchant")); // for a[1][2]
pbstr[8] = SysAllocString(OLESTR("Bussiness")); // for a[2][2]
SafeArrayUnaccessData(*ppOutputArray);
}
Thanks
George
|
|
|
|
|
georgekjolly wrote: a[0][0] = "Ram" , a[0][1] = "Lakhan" , a[0][2] = "Engineer"
a[1][0] = "Dipu" , a[1][1] = "Das" , a[1][2] = "Merchant"
a[2][0] = "Vinu" , a[2][1] = "Lal" , a[2][2] = "Bussiness"
**************************************************************/
// Here I have assigned my values, Is this the correct way of assigning values ??
pbstr[0] = SysAllocString(OLESTR("Ram")); // for a[0][0]
pbstr[1] = SysAllocString(OLESTR("Dipu")); // for a[1][0]
I think, you have messed up here.
Using Arrays of Strings[^].
This link will give you idea, how to use the array.
|
|
|
|
|
Hi Prasad,
Thank you Very much
George
|
|
|
|
|
Hi
How to start a interactive process(say calc.exe) on a remote machine USing WMIon Windows XP
Thanks In Advance
abhi
|
|
|
|
|