|
LCI wrote: pApp->arrPtr[i]->StartThread();
are you correctly assigning the Object for arrPtr[i]? as far you are not dereferencing the this pointer you can call a member function with invalid pointer.
void CClassB::StartThread()
{
_beginthread(MYBThread, 0, LPVOID(this));
}
in startThread function you are only passing the this pointer which is not deferenced, possibly IsOn is using the this pointer crashes the application.
|
|
|
|
|
I sort of see what you are saying. Can you expand a little?
Thanks,
|
|
|
|
|
are you sure arrPtr[i] contains valid object? debug it or show the code that fills the array.
|
|
|
|
|
I will check.
In my code i use it to make another function call in class B and all is well. However, the call in questiuon here is actually used within an "if" block. Scope should be ok though. I will check on it.
|
|
|
|
|
I am looking for a C++ function which can identify the architecture of an executable file (binary) e.g. whether it is a 32 bit or 64 bit. I heard such a function might be available in imagehlp.dll
Can somebody help?
|
|
|
|
|
harsha1305 wrote: I heard such a function might be available in imagehlp.dll
Excellent! Please post back what you find after reading the imagehlp documentation
|
|
|
|
|
led mike wrote: Excellent! Please post back what you find after reading the imagehlp documentation
he he he.. please let me know also... any way some voted you down, let me average it down!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/codeProject$$>
|
|
|
|
|
Like I care if monkeys on this site vote me down. I can still read documentation and develop my own software, monkey votes will never change that.
|
|
|
|
|
In imagehlp, maybe MapAndLoad()[^]
and LOADED_IMAGE.FileHeader.Machine.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Just curious, what did you find attractive about that bait?
|
|
|
|
|
Its wigglyness?
I was going to say "Someone has to do their research for them" until I saw the post below...
Apparently, somebody has to write the code for them
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Im feeling generous today. I created a function for you.
DWORD GetPEMachineType(LPTSTR sz)
{
HANDLE hFile = CreateFile(sz,GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
if(NULL != hFile)
{
LARGE_INTEGER bigInt;
BOOL diditWork = GetFileSizeEx(hFile, &bigInt);
HANDLE hFileMap = CreateFileMapping(hFile,NULL,PAGE_READWRITE,bigInt.HighPart,bigInt.LowPart + 0x2000 ,_T("someGUID"));
if(NULL != hFileMap)
{
LPVOID hMap = MapViewOfFile(hFileMap,FILE_MAP_READ,0,0,0);
if(NULL != hMap)
{
HMODULE hModule = (HMODULE)hMap;
IMAGE_DOS_HEADER * pDosHeader = (IMAGE_DOS_HEADER *)hModule;
IMAGE_FILE_HEADER * pFileHeader = (IMAGE_FILE_HEADER *)(((LPBYTE)hModule) + pDosHeader->e_lfanew + sizeof(IMAGE_NT_SIGNATURE));
return pFileHeader->Machine;
}
}
}
}
Here is a link to the current PE format specification:
http://www.microsoft.com/whdc/system/platform/firmware/PECOFF.mspx[^]
The possibilities include:
IMAGE_FILE_MACHINE_UNKNOWN 0x0 The contents of this field are assumed to be applicable to any machine type
IMAGE_FILE_MACHINE_AM33 0x1d3 Matsushita AM33
IMAGE_FILE_MACHINE_AMD64 0x8664 x64
IMAGE_FILE_MACHINE_ARM 0x1c0 ARM little endian
IMAGE_FILE_MACHINE_EBC 0xebc EFI byte code
IMAGE_FILE_MACHINE_I386 0x14c Intel 386 or later processors and compatible processors
IMAGE_FILE_MACHINE_IA64 0x200 Intel Itanium processor family
IMAGE_FILE_MACHINE_M32R 0x9041 Mitsubishi M32R little endian
IMAGE_FILE_MACHINE_MIPS16 0x266 MIPS16
IMAGE_FILE_MACHINE_MIPSFPU 0x366 MIPS with FPU
IMAGE_FILE_MACHINE_MIPSFPU16 0x466 MIPS16 with FPU
IMAGE_FILE_MACHINE_POWERPC 0x1f0 Power PC little endian
IMAGE_FILE_MACHINE_POWERPCFP 0x1f1 Power PC with floating point support
IMAGE_FILE_MACHINE_R4000 0x166 MIPS little endian
IMAGE_FILE_MACHINE_SH3 0x1a2 Hitachi SH3
IMAGE_FILE_MACHINE_SH3DSP 0x1a3 Hitachi SH3 DSP
IMAGE_FILE_MACHINE_SH4 0x1a6 Hitachi SH4
IMAGE_FILE_MACHINE_SH5 0x1a8 Hitachi SH5
IMAGE_FILE_MACHINE_THUMB 0x1c2 Thumb
IMAGE_FILE_MACHINE_WCEMIPSV2 0x169 MIPS little-endian WCE v2
Best Wishes,
-David Delaune
modified on Thursday, March 13, 2008 4:32 PM
|
|
|
|
|
Randor wrote: Im feeling generous today. I created a function for you.
Now all you have to do is hope you never have to work with him since you may have just helped him stay employed in the industry.
|
|
|
|
|
Look on the bright side, thats one less homeless person to worry about.
-David Delaune
|
|
|
|
|
Randor wrote: Look on the bright side, thats one less homeless person to worry about.
RIght you say! 5 point!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/codeProject$$>
|
|
|
|
|
Buddy, i also igree with you. My 5! for his all reply in this topic.
|
|
|
|
|
|
I have included your tip in my site...!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/codeProject$$>
|
|
|
|
|
I'm using a "for" loop which repeats many times and has the potential to be time consuming. I want to be able to break out of the loop when the user hits some key to cancel the operation. The only way I have found to do this is to call GetAsyncKeyState from within the loop, and break out of the loop when it indicates a key has been pressed since the last check was made.
Is this a good way to do this check, or is there some other, better way?
Thanks in advance.

|
|
|
|
|
Californian2 wrote: Is this a good way to do this check, or is there some other, better way?
A better way is to give a cancel button, and pump the messages manually within the loop.
[ADD] See here[^] [/ADD]
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
What do you mean by "pump the messages manually within the loop"?

|
|
|
|
|
I've modified my previous reply to you to add a reference. Please have a look at it.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Are threads not allowed here?
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
Best wishes to Rexx[^]
|
|
|
|
|
VuNic wrote: Are threads not allowed here?
I don't see what you're smoking, but threads are allowed here. Mostly, the threads will all be related to Visual C++ / MFC.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
lol PostQuitMessage("Goodnight!");
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
Best wishes to Rexx[^]
|
|
|
|