|
The problem was solved by a codeguru member:
CComVariant dpv[3];
dp.rgvarg = dpv;
I was not allocating space for the dp array structure.
Thank you very much for you reply. I believe your
dp.rgvarg = va;//your dispparam with you variant?
statement was in the same general direction too.
Thanks again.
Paradise is where I am.
Voltaire
|
|
|
|
|
I'm working on a c# application and i'd like to get it launchable from Microsoft Word using a new icon. The problem is I don't know how to do, I've been searching throw articles but they often explain how to launch and control Word from an application and not the contrary.
Could someone explain me how to do such a thing, or at least give me a few steps ?
Thank you.
---------
Or not ?
|
|
|
|
|
try http://www.codeproject.com/com/outlookaddin.asp for a C++/COM article on how to write a plugin for any office application. For sample C# project, checkout MSDN for an article that got published a couple of months back.To launch your own application, you can use ShellExec in OnClick of a toolbar button in your plugin.
|
|
|
|
|
Hi everybody,
I have added a toolbar button in Internet Explorer. This button should toggle the checkbox (and write/load some values from reg) in IE->Tools->Internet Options->Connections->LAN Settings called 'Use a proxy server'.
Q1: How can I design a COM object to receive the clicks of this button and keep track of the toggle state (button pushed/not pushed) and make the button look like a toggle button?
Q2: How can design my COM object to talk with the settings mentioned above? Is it possible?
Q3: I know how to change the reg settings that IE uses each time it starts. But I need to reflect this reg settings to IE at runtime. Does any one know how to do this if Q2 can't be achieved?
Thx a lot! I have a deadline in two days and I really need to get this working by then! So please all you COM pros out there, help me if you can!
I've just started out with COM...
Thx!!!
/Tommy
|
|
|
|
|
How can I define packed structure in IDL?
Most of compilers align structure in 4/8 bytes.
IN VC++ 6.0, we can control this by using '#pragma pack' directive.
But, how can we do the same thing in IDL?
I tried to using '#pragma pack' directive in IDL like we do in c++.
It looks successful only in COM-Server Project.
Compiler-made Header file in server project has '#pragma pack' directives enclosing structure-definition.
But, client project using '#import My.tlb' has failed.
My.tlh file defines this (I expect to be packed) as unpacked structure(maybe 8byte-align).
How can I define structure as packed?
I want structure to be packed in Header files made by MIDL(includes tlh).
And, Proxy/Stub code made automatically refelcts this.
How can I solve it?
thanks~
|
|
|
|
|
Hi, I'm not completely positive as I haven't tried this, but try using the #pragma pack directive like:
#pragma pack(push, 1)
#import ...
#pragma pack(pop)
Let me know if this works for you.
Mark
|
|
|
|
|
what is the value of this and why isn't it defined anywhere?? i have the latest platform SDK...
it is referenced in the Platform SDK file: "IActiveScriptParse::ParseScriptText"
- Roman -
|
|
|
|
|
Hi, all
In Atl project ,how can I return the user define type?
For example , I have define a Struct ,and I want to return the Struct type in a function, and I plan to utilize the return Struct type in VB through the com. What should I do ? I have try some ways ,but failed.
Another similar problem. I have two ATL Object in my Atl
project , Teacher and Student . And student is a private property of Teacher ,now I want to construct a function in Teacher to return the Student property .How should I do ?
Sincerely ask for help. Who can tell me how to do , or give me some similar source code which resovle the above problems .
I'll appreciate it .
Regards.
|
|
|
|
|
Q2. You can pass the IStudent interface as well as any other data from ITeacher interface.
Q1.
In IDL-file
typedef [uuid(XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX), helpstring("Help")]
struct _SomeStruct
{
int i;
BSTR str;
...
} SomeStruct;
[...,dual,...]
interface IO : IDispatch
{
[id(1)] HRESULT M1([in] SomeStruct ss);
[id(2)] HRESULT M2([in,out] SomeStruct *ss);
[id(3)] HRESULT M3([out,retval] SomeStruct* *ss);
[id(4)] HRESULT M4([in,out] SAFEARRAY(SomeStruct) * ssbs);
};
With best wishes,
Vita
|
|
|
|
|
thank you . Q1 has been resovled following your suggestion.
but Q2 remail abcuse.
I mean I can not construct the CStudent object in CTeacher.
Details as follows.
In the construction function of the CTeacher :
CTeacher()
{
IStudent * m_student =new CStudent();
return;
}
There are some compiler errors. It says that the CStudent cannot instantiate abstract class due to following members:QueryInterface,AddRef,Release.
How should I do to resolve the problem.
thx.
Regards.
|
|
|
|
|
If you are in ATL, you have several ways to do it.
1. With the class factory of CStudent.
if( FAILED(CStudent::_CreatorClass::CreateInstance(NULL,IID_IStudent, (void**)&m_student)) )
return E_FAIL;
2. With the static method of the generic ATL CComObject.
CComObject<CStudent>* pCStudent;
if( FAILED(pCStudent->CreateInstance(&pCStudent)) || FAILED(pCStudent->QueryInterface(&m_student)) )
return E_FAIL;
3. With the original COM method.
if( FAILED(CoCreateInstance(CLSID_Student,NULL,CLSCTX_ALL,IID_IStudent, (void**)&m_student)) )
return E_FAIL;
With best wishes,
Vita
|
|
|
|
|
Hi, all
Some problems about ATL Com:
1.I have create two ATL Object: CStudent and CTeacher .
The simple source code listed as follow: (some code auto generated by ATL have been skiped)
class CStudent
{
private:
long m_age;
public:
CStudent():m_age(10)
{
}
//...other code auto generated by ATL
};
class CTeacher
{
private:
IStudent* m_aStudent;
public:
CTeacher()
{
//create an instance of the com
CoCreateInstance(CLSID_Student,NULL,CLSCTX_ALL,IID_IStudent, (void**)&m_aStudent);
}
//...other code auto generated by ATL
}
2.Then I add a "IStudent * OneStudent" property for ITeacher ,to access the m_aStudent.
The implemention of the property are listed as below:
STDMETHODIMP CTeacher::get_OneStudent(IStudent *pVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
// TODO: Add your implementation code here
*pVal = * m_aStudent;
return S_OK;
}
STDMETHODIMP CTeacher::put_OneStudent(IStudent *newVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
// TODO: Add your implementation code here
*m_aStudent = *newVal ;
return S_OK;
}
3.Now I type some VB code to test the com ,but some compiler errors occurrs.
VB Code:
Dim s As Student
Dim t As New Teacher
s = t.OneStudent
the last sentence "s = t.OneStudent" have compiler errors.
Errors:function or interface marked as restricted ,or the function use an Automation type not supported in Visual Basic
I guess the errors caused by the type dismatch between IStudnet and CStudent.But I did not know how to resolve it .
So who can tell me how to return the m_aStudent that can be supproted in vb??
thx.
Regards.
|
|
|
|
|
I think that you should implement get_OneStudent that way (and the IDL updated appropriatly):
STDMETHODIMP CTeacher::get_OneStudent(IStudent **pVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = m_aStudent;
if (*pVal) {
(*pVal)->AddRef();
}
return S_OK;
}
You cannot copy the interface (nothing will be copied since the interface has no data in itself) and output parameter must be a [out]pointer to what you want to returns (you want to returns a IStudent * so you must use IStudent **).
Philippe Mori
|
|
|
|
|
I need to use activex dll created in vb in a C++ program. I use vc 6.
Here is what I do:
#import " MADLL1.dll" \<br />
named_guids no_implementation \<br />
raw_interfaces_only raw_native_types<br />
using namespace MADLL1;<br />
<br />
#import " MADLL2.dll" no_implementation \<br />
no_auto_exclude \<br />
raw_native_types raw_interfaces_only \<br />
named_guids <br />
using namespace MADLL2;<br />
<br />
#import " MADLL3.dll" no_implementation \<br />
no_auto_exclude \<br />
raw_native_types raw_interfaces_only \<br />
named_guids rename("SOMETHING"," SOMETHINGX") \<br />
rename(" SOMETHINGELSE", " SOMETHINGELSE X") \<br />
<br />
using namespace MADLL3;
My problem is with the third dll. I put rename because I had compilation errors.I taught It was name collision.
I did help with these variable but I have still alot of erros of the same kind:
Ex :
c:\inwork\opc_da_clientmerge\debug\OLEGEUSE.tlh(729) : error C2059: syntax error : 'constant'
enum TT_SOMETHING
{
TTDT_ONE = 0,///Here I should rename these variables
TTDT_TWO= 1,
TTDT_THREE= 2,
TTDT_FOUR= 3
};
Is it normal to rename everything? I don't think so.
Here is how I want to use the dll:
HRESULT hresult;<br />
CLSID clsid;<br />
<br />
CoInitialize(NULL);
hresult=CLSIDFromProgID(OLESTR("madll.clsConnexion"), &clsid);
if(FAILED(hresult))<br />
{<br />
<br />
TRACE_MSG(_T("CDataBD:: GetTypeAttr"),hresult);<br />
return hresult;<br />
} <br />
_clsConnexion *ConDll;
_clsError *Error;
hresult=CoCreateInstance(clsid,NULL,CLSCTX_INPROC_SERVER,__uuidof(_clsConnexion),(LPVOID *) &t);<br />
if(FAILED(hresult))<br />
{<br />
TRACE_MSG(_T("CDataBD:: GetTypeAttr"),hresult);<br />
return hresult;<br />
}
//to this point everything works
but for the rest I have to load the third dll to test it
ConDll ->LoadData("01", "L4", 0, 0, m_Line, "OLE.MachineS", ADO_OLEDB, Error);<br />
ConDll->Release();
CoUninitialize();
I also tried with IDispatch
OLECHAR* name = OLESTR("LoadData"); <br />
HRESULT hr2 = pDispatch->GetIDsOfNames(IID_NULL,<br />
&name,<br />
1,<br />
GetUserDefaultLCID(),<br />
&dispid);
Thinking I could use Invoke....
But I received :
DISP_E_UNKNOWNNAME
I'm able to use these Interfaces :
ITypeLib
ITypeInfo
I have access to info from the lib but not Invoke...
You see that I tried different approches without success.
Is it me that don't understand or could it be how the dll was created?
I have access to source code from dll but can't change anything.
Hope somebody could help me
Regards
Lily
|
|
|
|
|
Hi there,
My guess is that MADLL3 typelibrary implicitly imports typelibs of MADLL2 or MADLL1, this causes all kinds of typedefs to be duplicated in the generated .tlh and .tli files.
Gertjan
|
|
|
|
|
when make a ComAddin:
in VB
Private Sub AddinInstance_OnConnection(ByVal Application As Object,
ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode,
ByVal AddInInst As Object,
custom() As Variant)
AddInInst.object = Me
End Sub
in MFC
STDMETHODIMP CMyAddin::OnConnection(IDispatch* Application,
ext_ConnectMode ConnectMode,
IDispatch* AddInInst,
LPSAFEARRAY* custom)
{
return S_OK;
}
Question is :
How to do (AddInInst.object = Me) in the MFC?
|
|
|
|
|
Please help me.
How to Call ComAddin's function from VBA MACRO?
|
|
|
|
|
I have to convert a TCHAR string to BSTR in an ATL based service without using MFC.
I tried T2OLE, but I could not compile the project because some errors:
'_lpa' : undeclared identifier, ...
Could anyone help me out?
Alma
|
|
|
|
|
You can use CComBSTR class to make this conversion.
CComBSTR bstrString( tcharString );
or
bstrString = tcharOtherString;
With best wishes,
Vita
|
|
|
|
|
|
The string conversion macros require that you put the USES_CONVERSION; macro at the beginning of the function/block.
--Mike--
Just released - RightClick-Encrypt v1.3 - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Your getting this error because your not using the USES_CONVERSION macro in your functions that use the T2OLE macro. For example:
void myfunc(LPTSTR szIN, BSTR* bszOut){
USES_CONVERSION;
bszOut = T2OLE(szIN);
}
Hope that helps.
|
|
|
|
|
Yep, it workes this way. Thanks.
|
|
|
|
|
Hi!
I am new to COM / ATL and just trying to learn that...
I want to have a ATL COM Component with a dialog box with all its message handeling in it and want to show up that dialog in some other Client app using some interface etc.
Pls tell me how to do that. I will be thankful if you can give me detailed tutorial kind ....specifying all steps ..as I am new to it.
One more another question....
Actually my need is that my client ( a win32 SDK project without MFC) has a method which adds property Sheets and all it needs is a Dialog Resource ID and Callback function of that dialog to add propertysheet to existing propertysheet. Now I want a com dll having that property sheet. I would like to know how to do that ...Pls help . What I should do to make COM Dll and how to get Dialog ID and callback function in Client...
I would love to have some code/ project examples
thanks
Naveen
|
|
|
|
|
I need to implement IDispatch::GetIDSOfNames without creating type library, i.e. I need to return certain ID for certain name. How??
|
|
|
|