|
I'm writing a C++ console app for Windows and UNIX. When it runs, the app needs to know the directory where it's located. Of course, this may or may not be different from the working directory (which I don't care about). I need the directory where the app's file is at -- the equivalent of GetModuleFileName on Windows.
Anyone have a clue?
Thanks,
Alvaro
|
|
|
|
|
There are many flavors of UNIX. You will need to look at the system calls available for the flavor you are coding for.
|
|
|
|
|
> When it runs, the app needs to know the directory where it's located.
Check the first argument passed to "main(...)". That usually contains the path to the executable.
-=- James.
|
|
|
|
|
I am using SDI project' original printing, but for some reason what is being printed is much smaller that what is it in my screen: I know that I should be using SetMapMode but I have no clue how! Please give me some help, I'd really appreciate you comments.
thank-you
// pDC->SetMapMode(MM_TEXT*10);
for(int i=0;i<ind2-1;i++)
{
="" pdc-="">MoveTo(xypoint[i]);
pDC->LineTo(xypoint[i+1]);
}
But lines are printed much smaller than they what are.(they are smaller in printpreview either)
|
|
|
|
|
Trying to make the screen display actually the same size as a hard copy is basically impossible (Not really but in my opinion impractical). The standard program does not care if you are using a 21" monitor or a 15" monitor. It has a defined screen resolution independent of the phiysical size.
The mapping modes work with the device driver for hard copy printout to produce an acurate placement.
Most of the tutorial books cover the basics of this. My personal favorite starting point is Kruglinski's Inside Visual C++ Forth Edition. This will not go into the underlying details like Petzolts book but will get you started.
Michael A Barnhart
mabtech@swbell.net
|
|
|
|
|
why do we need to do something like mask & 1010101??
Thanks for answering
|
|
|
|
|
why do we need to do something like mask & 1010101??
Thanks for answering
|
|
|
|
|
bitmasking lets you use an unsigned datatype as a collection of flags. If you use an int then you get 32 flags that you can set. To set any of the flags you would use
var |= FlagToSet
and to check if a flag (single bit) is set you would
if (var & FlagToCheck)
which will check on a bit by bit basis and return the result. If the bit(s) specified in FlagToCheck are not set in var then the result will be 0. If any of the flags are set then it will be nonzero (actual result based on which bits are set).
|
|
|
|
|
For intercepting Messages from window applications.. Is it better to use Hook functions (SetWinEventHook) or uses Interface methods (PointConnection, IID...)?
|
|
|
|
|
There are two acceptable methods that I have used in the past.
1. Inserting a Windows Message hook which I put behind a edit control in
a separate process so I could make my windows enable and disable
depending on the content of the edit.
This worked fine and ended up being very little code, however it did
have to be in a separate DLL. (You'll want to use Spy to help you!)
2. Subclassing. I have done subclassing before but have found it confusing
when doing anything other than the simple case. This could have just
been me as I was a novice at the time.
J
|
|
|
|
|
I have a class that is derived from the CAsyncSocket class. This is used to monitor a socket on machine and works fine when used with an application. I would like to use this with a NT service. I have limited experience with services. I have read some (most?) of the MSDN documentation but feel (hope) that I must be missing some critical issues. In reviewing samples available (Nigel's work on the MS site, Koeing's and Naughters samples on the CodeGuru site) I find that all are using a loop step through until a stop command is issued which then breaks the loop. TO keep the service from running 100% a sleep command is issued. It appears that when a sleep call is issued the service is then not monitoring the socket which defeats its purpose. SO:
1) Can someone confirm I am correct here.
2) Any suggestions - a pointer to some documentation is fine. I do not mind working on this just am at somewhat of a dead end with what I have found (understand) to date.
A web server must be doing something simmilar to what I need.
Thanks
Michael A Barnhart
mabtech@swbell.net
|
|
|
|
|
I found what the issue is. It is not a sleep idle variation, MFC socket classes rely on messages posted to a window, which my service does not have.
Michael A Barnhart
mabtech@swbell.net
|
|
|
|
|
I was just wondering. I'm using a third party DLL in an application. I DO have both a release and debug build of the DLL (though no source). I have a full spec of the DLL and know what each function is supposed to do. Is there some way I can 'hook' the DLL in such a way as to 'spy' on it?
|
|
|
|
|
There are a variety of ways:-
Take a look at the deadlock detector by John Robbins in MSJ a year or so back.
That shows one way.
Alternateively write wrapper functions for each function in the DLL and call
your wrapper functions rather than call the DLL directly. Put your 'spy' code
in there.
I've also developed another technique, which uses a fair bit of assembly to
mess about with function APIs to do the job, but that has taken me a year and is
part of a product that will be for sale at some point. As you can imagine,
I'm not about to part with that info. Sorry.
Finally there is a company 'Sarion' I think that sells a product called 'APIus'
which looks like it might do the job you want. I've seen adverts in MSJ/DDJ/WDJ
for it.
Stephen Kellett
|
|
|
|
|
Hello,
i want to visualize a large (1000m x 200m) depot, but using CBmp is blasting my memory. So im lokking for a different way. Anyone got an idea ?
Greets Matthias Schikowsky
|
|
|
|
|
So,
i came across Metafiles. But is it possible to use this method, and if so, how ?
MS
|
|
|
|
|
I look for sample code for capture messages from a window application (like Spy++)
Thanks!
|
|
|
|
|
Tom the source for SPY++ is included with the PLATFORM SDK.
|
|
|
|
|
The only sample i've found is "ControlSpy" but it's not the code source of Spy++!!
|
|
|
|
|
if have an array declared as
> CObArray m_arrRadio;
and i want to add pointers to this array of the following class:
> class CRgbRadio : public CObject
> {
> public:
> int m_iCtrlId;
> int m_iValue;
> };
... and this is the code, where the assertion occurs:
> CRgbRadio* pRadio = new CRgbRadio();
> pRadio->m_iCtrlId = 100;
> pRadio->m_iValue = 1;
> m_arrRadio.Add( pRadio );
while executing the Add-statement i get an assertion in line 182 of the file 'array_o.cpp'. the debug-windows shows the following information:
> ASSERT_VALID fails with illegal vtable pointer.
can anyone explain to me, what's wrong with the code
peter
|
|
|
|
|
Isn't it necessary to use the IMPLEMENT_SERIAL macro when you derive a class from CObject?
What does the code:
CRGBRadio radio;
radio.m_iCtrlID = 100;
radio.m_iValue = 1;
m_arrRadio.Add(&radio);
do?
Just curious: (Seeing the word "RGB") Where are you using it for? Do you have any (usefull) code to convert from RGB to CMYK and vice versa? (Without any loss)
--
Alex Marbus
|
|
|
|
|
unfortunately i must disappoint you. 'RGB' does not have in this reflects anything with a color palette. it is the abbreviation of my project! perhaps, you may right that this somewhat unfortunately on selected.
i doubt, whether i need the IMPLEMENT_SERIAL macro. i nothing want to serialize but want to store pointers in a list. by the way, i get with the macro the same error message.
peter
|
|
|
|
|
Maybe you need to declare a constructor, a destructor, and/or a copy constructor for your class. Perhaps some hidden assignment is causing one of these 'defaults' to be invoked on your object.
|
|
|
|
|
Dear All,
I have developed an application with VC++6sp4 on WinNT4sp6 and everything is fine and dandy. The big problem occurs when I compile the same code on a Win98 machine. All calls to Loadstring fail returning an empty string.
I was wondering if anyone else has experienced this behaviour, and if so how to go about fixing it
Thanks inadvance
Lea
|
|
|
|
|
Lea,
can't say I've ever had this problem. I presume you are refering to the WIN32 API version of LoadString? Looking at it in the MSDN my first guess was that maybe you are having buffer problems, NT being UNICODE and Win98 being...well what is it exactly? (sorry that was not very helpfull was it).
My advice is to try using the API call GetLastError(), which will return you an error code (that may have been set by the LoadString call).
There is an error list in the MSDN some where which will help you decipher what the error code means.
Accept that some days you are the pigeon and some days the statue.
|
|
|
|