|
Hmm.. never send a copy of a BSTR to a COM method. That means that the method is responsible for cleaning up the string. This however is against COM rules, as [in] parameters MUST be managed by the caller. If the string has to be marshalled through the method call, then the string passed in will be lost (memory leak), and the callee will free a bstr which it does not own (the marshaller owns it).
Thus, if you are using a _bstr_t or a CComBSTR, pass the BSTR pointer (or adress of if passing as an [out] argument) managed by these classes.
[in] parameters are managed by called
[out] parameters are allocated by callee, and passed for ownership to caller
--
Ich bin Joachim von Hassel, und ich bin Pilot der Bundeswehr.
Welle: Erdball - F104-G Starfighter
|
|
|
|
|
Hi!
I recently upgraded from VC 6.0 to VS.net 2002. I am using WTL v7.0. I created a simple modal dialog application and added a web browser control to it. The compilation was successful but the application refuses to create a dialog. Can anyone tell me what I should do to get my app up and running?
After this happened, I created a similar project in VC 6.0 and it seems to work well there.
When I open the same project (that I created in VC 6.0) in vs.net 2002 and convert it to VC 7.0 project and compile it, I get a problem
hRes = _Module.Init(NULL, hInstance);
I replaced this piece of code with
hRes = _Module.Init(NULL, hInstance, &LIBID_ATLLib);
I presume this is because of some ATL incompatibility?!
Can anyone please help me with this?
Thanks!
Ram
|
|
|
|
|
Hi,erveryone, I don't know how to debug my asp component,Can you help me ?Thanks!
|
|
|
|
|
You need to register the DLL in MTS or Component Services first. I will assume you are in Windows 2000/XP so I'll refer to those. Using MTS, the procedure is analogous.
1.- In Component Services, right click on the Application containing your component. Click properties.
2.- Copy the Application ID to clipboard
3.- In Visual C++ with your component project opened. Go to Project Settings.
4.- Be sure it is selected Debug configuration. Go to Debug Tab.
5.- Under "Executable for debug session:" write:
C:\WINNT\system32\DLLHOST.EXE (obviously the path should be the path where DLLHOST.EXE file is in your system)
6.- Under "Program arguments:" write:
/ProcessId:{the application ID you previously copied to clipboard}
7.- Now place a breakpoint where you want to start debugging
8.- Run the component (you will be warned that DLLHOST.EXE doesn't have debug information... just click OK)
9.- Run your ASP Page. When the breakpoint is reached, Visual C++ IDE will be activated for you to continue debugging your component as any Visual C++ program.
10.- If you make changes to your component, you may need to shutdown the component services Application before you can debug it again.
I hope this helps
Jaime
|
|
|
|
|
Hi,
I am developing multithreading COM EXE server. In one of the methods I have called CoCreateInstance, which is made threadsafe by using CSingleLock(&(oneMutext)). After some time of server starts, this CoCreateInstance raises an exception. Also heap get corrupted at this instance.
Can anybody help me in resolving this issue.
Mandar
|
|
|
|
|
Where can I find WTL reference to download it, including explanations of every member functions and variables for every class?
Fore Thanks
Ajnstajn
|
|
|
|
|
Does not exist. CodeProject may have the best collection of WTL stuff available. Search Articles for WTL.
-pete
|
|
|
|
|
|
I think m_spBrowser is in CScanCtl.
|
|
|
|
|
Is there a way in ATL to debug CoTaskMemAlloc/Realloc calls and make sure that CoTaskMemFree was called for every allocation?
thanks
Man Learns from History that he never learns from History
|
|
|
|
|
|
Hi,
I'm having some difficulty implementing a variably multidimensional array.
Each dimension of the array needs to consist of exactly 23 elements, but the number of dimensions is user-specified.
For example the user could request an five dimensional array
int myArray[23][23][23][23][23];
or they could request an array of three dimensions
int myArray[23][23][23];
I know you can use pointers to vary the number elements in each dimension, but is there a way to vary the number of dimensions itself?
Thanks for any help you can give me, this is driving me mad!
Cheers
Mick
|
|
|
|
|
What do you mean number of dimensions? The number of elements in each dimension point to other dimensions.
Kuphryn
|
|
|
|
|
I am creating a COM interface to some library I have and I am trying to make an Initialize function that takes as it argument a SAFEARRAY of BSTR's.
I am using VS .NET 2000 and the ATL wizard. I added an object and am manually adding the entry for the function since SAFEARRAY is not an option for the auto-add member wizard. Here is what I have so far:
<br />
__interface IiidApplication : IDispatch<br />
{<br />
[id(1),helpstring("method Initialize")] HRESULT Initialize([in] SAFEARRAY(BSTR) *par); <br />
}<br />
Then later I have the function defined as STDMETHOD(Initialize)(LPSAFEARRAY pvar);
The IDL will not compile however. I get errors on the Initialize line complaining about an extra ) and missing ) and ; before *. If I remove the (BSTR) and just leave it as SAFEARRAY *par, it will not link because it complains about not knowing the size of the array or similar.
All the MS doc's seem to have the format as SAFEARRAY(your datatype) but it doesn't seem to be working for me. Any suggestions?
|
|
|
|
|
If i were you , i did better choose to use VARIANT type in the parameter passing and cast it to safe array later
This will make the COM more compatible with other languages
|
|
|
|
|
The satype attribute should be used in your case:
[id(1),helpstring("...")] HRESULT Initialize([in,satype(BSTR)] SAFEARRAY* *par);
With best wishes,
Vita
|
|
|
|
|
This is one of the interfaces in my project and it compiles without any problem in both Vc 6.0 and VS 2003. I have'nt tried VS.Net 2002 but it should work. The only difference is that mine is a IUnknown interface
<br />
interface IMyInterface : IUnknown<br />
{<br />
........<br />
HRESULT MyFunction( [in] SAFEARRAY(BSTR)* inputArray); <br />
};<br />
<br />
FYI,
The implementation of this method in ur .h must look like
<br />
STDMETHOD(MyFunction)(SAFEARRAY** inputArray); <br />
<br />
Hope this helps.
prashu
|
|
|
|
|
i use WTL wiz create MainFrame with menu\status\toolbar, it is strange that the toolbar flicker when resizing the frame. but there are many samples on this site not.
what is the trick ?
thx for your help.
|
|
|
|
|
may be repainting time of your tool bar is larger,or there are a large number of oject on your toolbar or you computer is infected by Toolbar Virus
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Hi all experts
I have a few COM type libraries from a vendor . In the type libraries, there is only interfaces without coclass
I am using visual c++, can any body show me a sample or teach me how to use the interfaces
thanks
|
|
|
|
|
I'm going to assume that you have the DLL or EXE that belong to each typelib.
Are you able to register the DLL/EXE ?
Can you create any object using VBA (Office) or VB if you add a reference to the typelib ?
DarkByte
|
|
|
|
|
Hi :
i have a set of dll that comes with the type lib.
yes i can register them. however i have also do an object view on all the dll
none of them contain the coclass referencing to the tlb
no i can't create any object using VBA
any other clue
thanks
|
|
|
|
|
Your DLL/EXE will also have the type information. Just reference that and you will be all set.
You can use OLEView to check if the DLL/EXE has the type information in it.
prashu
|
|
|
|
|
hi
i wrote an active x control with the microsoft visual studio .net
it handles the output from my webcam and lets it start and stop.
everything works fine, but just if I run the control on my computer.
on another maschine (also win xp) the control doesnt start in the
browser. (security settings allow it) i suppose i need to pack
some dlls into a cab file.
how do i find out which dll i need to pack into the cab file?
and how do i write the inf document.
beside the standard imports from an atl control project i just
added the #include <vfw.h>
standard imports
#include <afxctl.h> // MFC support for ActiveX Controls
#include <afxext.h> // MFC extensions
#include <afxdtctl.h> // MFC support for Internet Explorer 4 Comon Controls
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
// Delete the two includes below if you do not wish to use the MFC
// database classes
#include <afxdb.h> // MFC database classes
#include <afxdao.h> // MFC DAO database classes
#include <windows.h>
|
|
|
|
|
these are the includes:
I added:
#include <Vfw.h>
(standard active x stuff)
#include <afxctl.h> // MFC support for ActiveX Controls
#include <afxext.h> // MFC extensions
#include <afxdtctl.h> // MFC support for Internet Explorer 4 Comon Controls
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
// Delete the two includes below if you do not wish to use the MFC
// database classes
#include <afxdb.h> // MFC database classes
#include <afxdao.h> // MFC DAO database classes
#include <windows.h>
|
|
|
|