|
Your code has a bug.
Mike the Red wrote: _tcsncpy(szTemp, szPath, (size_t) (pdest + 1));
What do you expect here as the count parameter?
It is taking the value as an address plus 1.
This is going to be a very big value.
Another example of why typecasting must be avoided.
I wonder how it worked in a console application.
I tried it in a console application and it gave me the DEP error.
«_Superman_»
|
|
|
|
|
Thanks for the quick response, Superman!
That code you quoted (_tcsncpy(szTemp, szPath, (size_t) (pdest + 1)); ) was copied from the MS help file's example code for _tcsrchr . To be honest, I copied it without careful examination.
What I was expecting for the the count parameter was the index of the last \ in the file path.
GetModuleFileName returns the full path to the .DLL, say "c:\some path\This.DLL". I'm trying to extract the path and change the filename to the type lib's name, for instance "c:\some path\My.tlb".
Now that I re-read the helpfile on _tcsrchr , "Returns a pointer to the last occurrence of c in string, or NULL if c is not found", I actually have no idea how I would make use of this function.
At this point, I would probably manually iterate through the filepath string to find the index of the last \, then pull a substring and concatenate the type lib's filename. Is there a more efficient way to do this with the built-in string manipulation routines?
Thanks again for your help!
MZR
|
|
|
|
|
You must use _tsplitpath .
In the dir parameter you will get the path minus the filename.
Now you can concatenate the .tlb filename using _tcsncat_s .
«_Superman_»
|
|
|
|
|
I am currently writing an application using C++ and MFC. In this application I would like to be able to convert a string stored in an object of type CString to a C++ int. This string represents a signed integer. It seems to me that there should be a member function of the class CString to do this, but I have been unable to find such a member.
Thanks
Bob
|
|
|
|
|
I don't think CString should have a member function to do conversion to int.
CString is meant for dealing with strings.
You can convert using _wtoi like so.
CString cs = L"25";
int i = ::_wtoi(cs);
«_Superman_»
|
|
|
|
|
BobInNJ wrote: but I have been unable to find such a member.
because there is no such member.
you can also use _ttoi()
Regards,
Sandip.
|
|
|
|
|
See also StrToInt function [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
The easiest way is to search Google for "CString to int".
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
How can I distinguish between a hardware CDROM unit and a virtual one? I tried GetDriveType() but it doesn't ditinguish a DaemonTools Virtual unit from a real one.
In VC++ please...
36. When you surround an army, leave an outlet free.
...
Do not press a desperate foe too hard.
SUN-TZU - Art of War
|
|
|
|
|
Erm, that's kinda the POINT of things like daemontools. They spend a lot of effort to NOT be distinguishable. As far as the operating system is concerned it is a CDROM drive. Only at the deep driver level does it make a detour to look at a file on the hard disk, rather than a physical cd.
Iain,
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
Thanks! It's over my actual possibilities.
36. When you surround an army, leave an outlet free.
...
Do not press a desperate foe too hard.
SUN-TZU - Art of War
|
|
|
|
|
Such applications *normally* use a rootkit[^] to show itself to the OS as a Optical disk drive (or whatever it wants to appear to be). So, you'll have to write application that will detect a rootkit and find if it actually is hiding itself to provide a virtual disk drive capability.
There may be some X application that may not be using a rootkit. So, I don't see a "generic" approach to figure out this stuff.
A crude way is to note down the registry entries and folders all such applications create and look out if there's anything of that present in the machine. But if there were multiple drives (including actual optical drives), ...
Yours is an ambitious project, sir.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Thanks! It's over my possibilities.
36. When you surround an army, leave an outlet free.
...
Do not press a desperate foe too hard.
SUN-TZU - Art of War
|
|
|
|
|
I have to show the Pointer position on the Windows XP screen without over-write any information on the screen (like the mouse without using any GUI). Is there any way to do that or I have to use interrupt 33h? If in the latter case, how I do that in VC++ codes to call interrupt 33h?
Thanks for any help
modified on Monday, February 9, 2009 3:58 PM
|
|
|
|
|
THA2000 wrote: If in the latter case, how I do that in VC++ codes to call interrupt 33h? Most interrupts are not allowed/possible in Windows.
What exactly is it that you are after? Are you writing a console or a GUI application?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
I think I better off with the console because I would like to show the pointer moving around PC monitor
- I do not want to use any interrupt, but when the pointer moving I do not want it erasing any thing on the screen (like the mouse movements). Certailly, I have to provide the coordination to display the pointer ... but I do not know how to do it.
Can you help
|
|
|
|
|
Member 5928368 wrote: I think I better off with the console because I would like to show the pointer moving around PC monitor
The latter does not require the former. For what reason do you have to have a console application?
Member 5928368 wrote: ...but when the pointer moving I do not want it erasing any thing on the screen (like the mouse movements).
I'm not sure what you are saying here, but the mouse does not normally erase anything as it moves around on the screen.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Yes, you are right! Sorry my statement were not clear enough, I would like to display the pointer on the monitor (as the mouse) which not erase any thing when it pass over!
To do the above mentioned, even with VC++ console or MFC or any thing within VC6.0, then it will be oK for me!
For now, I do not know how to do that
|
|
|
|
|
THA2000 wrote: To do the above mentioned, even with VC++ console or MFC or any thing within VC6.0, then it will be oK for me!
The simplest way is to create a dialog-based applicaton, call SetCapture() , and then respond to the WM_MOUSEMOVE message. When you are done, be sure and call ReleaseCapture() .
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Thank for the suggestion, but I am not sure that I can display my pointer as I wish? Let say I would like to display my pointer (not the mouse position) at the top-left sreen then at the bottom-right of the screen (1280 x 800 resolution) ... what can I do?
Thanks in-advanced
|
|
|
|
|
THA2000 wrote: Let say I would like to display my pointer (not the mouse position) at the top-left sreen then at the bottom-right of the screen (1280 x 800 resolution) ... what can I do?
Call SetCursorPos() .
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
It works beautifully, however I wonder that: Can I not use the Dialog base? Because I still have the dialog apprearing on the screen, by any chance we don't have to do that?
Anyway, thanks a lot for help
|
|
|
|
|
Your best bet is to just try it and see.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Try searching for these:
FindWindow(<string>) (MFC)
CLSID_ActiveDesktop (COM)
CreateDC("DISPLAY",NULL,NULL,NULL) (MFC)
though I'm also not sure what exactly you're looking for (an interrupt for mouse movement?), the first will get you an HWND to whatever window you want ("progman" is the top level window), from which you can get almost any information you need... the second lets you adjust the desktop, and the third is involved in painting the screen, in case you wanted to capture the screen.
If your window has focus, maybe handle the ON_WM_MOUSEMOVE event (MFC)
...
I also remember capturing the mouse coordinates with a simple DJGPP graphics library circa 2000, so there're probably other ways of doing THAT.
|
|
|
|
|
As I just mentionned (in other reply) that I do not want to use any interrupt (but I am not sure do I need it or not) to show the pointer moving around the monitor screen without erasing any thing on it (as the mouse movement)
Can we do it. If Yes, then how I do it & is there any sample available
Can you help me
|
|
|
|