|
Thanks Rob, it works perfectly!
|
|
|
|
|
RTTI - good or bad? I am using ATL/WTL and by default, new projects created using VS.NET have RTTI disabled. Before I rush off and use dynamic_cast are there any known gotchas with using RTTI? Will it make a difference to my program size, etc.?
I used to use "IsKindOf(RUNTIME_CLASS(...))" in my MFC days, though I'll admit that is makes some code look ugly and kinda feels like a kludge.
Thoughts?
When I am king, you will be first against the wall.
|
|
|
|
|
I use it all the time now in my MFC code and stay away from the "IsKindOf(RUNTIME_CLASS(...))" stuff...
John
|
|
|
|
|
It *could* slow down your application a little bit, but in most cases you won't notice any difference.
|
|
|
|
|
Well I guess it has to store the RTTI info so my program size will increase too I guess.
I found some more info in Effective C++ too:
"...the space cost of RTTI is an additional entry in each class vtbl plus the cost of the storage for the type_info object for each class. Just as the memory for virtual tables is unlikely to be noticeable for most applications, however, you're unlikely to run into problems due to the size of type_info objects."
So I should probably give it a go - it can be very handy...
When I am king, you will be first against the wall.
|
|
|
|
|
It adds some overhead to the application (both size and runtime). It's usually negligible, but the reason why it's off by default.
You get into trouble, however, if you try to link to a .LIB which is compiled without RTTI
"Der Geist des Kriegers ist erwacht / Ich hab die Macht" StS
sighist | Agile Programming | doxygen
|
|
|
|
|
Are there additional mix&match rules about using RTTI? May I create a .DLL (class library) with RTTI and link to it from non-RTTI EXE's?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
Santa Cruz Networks
|
|
|
|
|
Might be a problem when the DLL exports classes. After all, if you compile the DLL without RTTI, and later request RTTI from the DLL-implemented class, something strange will happen.
I guess the C++ name decoration is different for compiles with/without RTTI, so it won't find the correct exports in a RTTI setting mismatch.
"Der Geist des Kriegers ist erwacht / Ich hab die Macht" StS
sighist | Agile Programming | doxygen
|
|
|
|
|
I don't think you will have any problems either way as long as you don't try to use RTTI on code that was not compiled with it. I write all my code with RTTI turned on and I know the libraries that my coworkers give me do not have RTTI turned on but it does not seem to cause any problems. However when I think of it they do give me a simple class interface with no inheritance or virtual functions so maybe the problems occur when the code uses these features. When this subject was brought up I was thinking of MFC. I do use RTTI with MFC all the time. Was MFC 4.1 compiled with this turned on??
John
|
|
|
|
|
I use it all the time for the VCF, and use dynamic_cast as a replacement for QueryInterface type of functionality. Haven't seen any real issues with it.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
|
|
|
|
|
Hi All
i have been given a dll file, which i need to import into my
.net c++ application, as i need to access some of the functions
defined in DLL
However i havent ever done anything on dll's and importing them into
a project and have no idea where to start
can ne1 help or point me in the right direction
thanks
simon
|
|
|
|
|
This is not my strong point, but I've done this a few times in the past.
Some questions first:
1) Do you already know the API? Is it a C++ or C or other style API?
2) Does it come with .H files?
3) Does it come with .LIB file? (this *may* be generated)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
Santa Cruz Networks
|
|
|
|
|
Hi Peter
I dont know what style the API is in, the DLL has been supplied to me
from an external company, at a guess i would say it was probably written in VB or delphi
it doesnt come with any .h files or .lib files, all i have been
supplied with is a single dll file
any ideas ???
thnaks
simon
|
|
|
|
|
Uhhhh....
You got this DLL from an external source. They provided you with nothing except the DLL file?
What does this DLL do? Do you know anything about what you're supposed to do with it? Or what function you are supposed to call? Or....
What exactly do you know about this DLL?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
Santa Cruz Networks
|
|
|
|
|
Hi Peter
what it is, is im writing an application which access's an external
company's database, however they wont, for security reasons allow me
to access the database directly, instead they have provided me
with this DLL, which contains exported functions from another program
which i then call to obtain the data which i require
|
|
|
|
|
So, there's 2 parts to this problem.
1) How to get access to the DLL and it's functions
2) How to integrate this into your program.
(1) access -- Get familiar with LoadLibrary and GetProcAddress. LoadLibrary will load the DLL into memory. GetProcAddress will probe the loaded DLL for it's entrypoints (functions). You should also understand "pointers to functions" and how to represent those in C++ code.
(A) Create a prototype for the function you want to call. This prototype declares a function pointer:
typedef int (FAR PASCAL *FunctionPrototypeName)();
note that the FAR PASCAL identifiers are defined by whoever wrote the DLL. This defines the "calling convention" used in the function. Get this info from whoever wrote the DLL.
(B) Declare storage for this pointer. Global variable is fine. [Consider wrapping all this stuff in a C++ class, i.e. represent the DLL as a class, compartmentalizing access to the DLL through the class. Abstract each entrypoint of the DLL into a C++ member function.]
FunctionPrototypeName fp_function;
(C) In code, load the library:
HMODULE hDLL = LoadLibrary( _T("MyDLL.DLL" );
(D) Load the pointer to the function:
fp_function= (FunctionPrototypeName)GetProcAddress( hDLL, "ExportedFunctionName" );
(E) The function is now ready to be called:
int x = (*fp_function)()
(2) integration
As I mentioned in a note above. Represent the DLL as a C++ class. Each entry point in the DLL, should be represented by an member function in the C++ class.
-p
P.S. I can't guarantee my syntax is perfect. Compile errors may occur. Mileage may vary. Do not bend, spindle, or mutilate.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
Santa Cruz Networks
|
|
|
|
|
Hey lads,
Is it possible to handle a ON_REGISTERED_MESSAGE message in a CWinApp derived class... Keeps giving me static_cast errors... I don't have the code with me now... It was 1am this morning that I was doing it and I didn't even get a chance to look at the messge properly before I fell alseep.
Think it was somethign to do with a cast from CWnd to CWinApp. ON_REGISTERED_MESSAGE a macro that only works with CWnd?
Regards,
Brian Dela
|
|
|
|
|
when i open mmc.exe (microsoft managment console)there is a default menu items
'Action' 'View' & 'Favourites'
i opened sql server enterprise manager which is uses the mmc and i notice that the last menu item was 'Tools'....
(i have a snap-in object project)
i need to produce such an item...but don't know how?
can any1 help please?
thanks in advanced,
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
Does anybody know how to scan avalible wireless (802.11b) network in a MFC program?
Any tips will be appreicated!
mao
|
|
|
|
|
What do you mean by "scan wireless network?"
|
|
|
|
|
What "scan wireless network" means enum all avalible 802.11b wireless network on air.
Sometime, there are more than one AP (access point) or Adhoc network avalible on air. I want to enum all the avalible network and then let user choose to connect one of them.
DavidCrow wrote:
What do you mean by "scan wireless network?"
|
|
|
|
|
Take a look at the DDK documentation for 802_11 OIDs. For example, an application can send OID_802_11_SCAN_LIST to ask the miniport driver to do active or passive scan. This list is then returned to the application. User Mode applications cannot send OIDs directly to the miniport therefore you have to have a protocol driver in between to do this correctly. On Xp the zero config service uses a variation of "User Mode I/O" protocol driver (in the DDK Samples) to send these OIDs. Some vendors implement private IOCTL codes in the miniport, in that case application can just send IOCTLs directly to the miniport.
|
|
|
|
|
thank you very much, it sounds ok, i will try this way.
|
|
|
|
|
Thank you very much for your help.
After I studied some DDK documents, I relized you r a real expert in this area!
Since WinXP introduced a WZC service, does this mean in an XP box, I needn't write a NDISUIO driver myself, instead I can use WZC to do everything I want?
However I searched MS site and found very few information on WZC, almost get no information on how to use WZC service at all. Could you give me more tips?
Thanks so!
|
|
|
|
|
Does anyone know how to change network and adapter setting in a MFC program?
It can be easily done by hand, just right click on a network connection and select "Properties" to make changes. However how to do that in a program?
I found a very useful program by IBM, named "Access Connection" (http://www.pc.ibm.com/qtechinfo/MIGR-4ZLNJB.html?doctype=Downloadable+files) can do this. I am trying to write a simular program.
Any help is appreciated!
|
|
|
|