|
> How do I do to make APDU appear the type in the curtain menu that show the
possible types??
You don't. Just type your type. All you have to make sure is that the IDL compiler recognizes your type. May or may not be easy.
--
Ich bin Joachim von Hassel, und ich bin Pilot der Bundeswehr.
Welle: Erdball - F104-G Starfighter
|
|
|
|
|
Hi
I have a component implementing a proprietary protocol (say,
Protocol.dll)and does the communciation over serial port. I have defined ATL
objects for each type of packet, and nearly all has a property called
"description" which returns a BSTR.
One ATL object encapsulates the serial communication. So I can set the baud
rate, port number etc.
A connection point event is defined corresponding to each packet that may
arrive to the PC (from the device). Say ProtocolPkt1, ProtocolPkt2,
ProtocolPkt3 etc.
Now we typically use 2 serial ports. One that does proper protocol
communciation and another that dumps trace staements. To take care of the
trace statements I have one event defined (LogData) in the same event
interface described above.
I have an application (say Mainwindow.exe) that uses the above component,
connects to both the ports and has separate event sinks to handle the 2
ports separately. The protocol data and the log data coming from the 2 ports
are to be shown in separate windows. Whenever an event notifies that log
data is received it is simply dumped in a window. Whenever any event
notifying any of the protocol packets is received, the corresponding packet
is created from the bytes received in the event, interpreted and displayed.
Now onto the problem. When some protocol packets are received, the
description property has to be called. When both the ports are connected the
log data comes fine. But when the description property of say ProtocolPkt1
event is called, the BSTR returned is prefixed with some log string that
came in the LogData event. Further the application displays a crash when it
is closed.
Some more observations.
1. This does not happen when the BSTR returned is very short. Typically only
when the string returned is long and computed in some for loop, does this
corruption occur.
2. This does not happen when I use the debug version of Protocol.dll.
I hope I have made myself clear. If any information is required please let
me know. Any pointers that can help me proceed would be greatly appreaciated
Thanks
aby
|
|
|
|
|
>> 2. This does not happen when I use the debug version of Protocol.dll.
Have you tried looking at this article Surviving the Release Version?
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
Make sure that the code that fires the event manages the life time of the BSTR.
I suspect that the first client is releasing the BSTR and hence ur second client sees garbage.
For events and BSTR the caller allocates and frees the bstr. if u are using _bstr_t always pass a copy to the event( bstrVar.copy())
Hope this helps..
prashu
|
|
|
|
|
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
|
|
|
|