|
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[^]
|
|
|
|
|
This operation is actually within a dll, and I won't be controlling various threads.

|
|
|
|
|
no! no multithreading is allowed here
"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 going to start getting back "into" some coding again after a hiatus (actually it's a fairly long one, though I did briefly do some stuff for work here). I've always used Visual Studio 6 and C++/MFC. I have a new vista laptop and even after the patches, found that my shiny new VS 2005 that work bought for me doesn't always work properly when writing simple dialog apps with controls. On the whole, that's the kind of thing I would like to do a lot of, though I will try out "proper" MDI applications at some point.
My point is this - I see a lot written now about .NET and C#, am I better off looking at that and learning those from scratch, or should I just refresh and improve my knowledge with C++/MFC in particular. These won't likely be "hardcore" industrial apps, but I would like to write things that are a bit more robust at some point.
I think at work they might well get an old VS installed at some point, maybe even v6, but at home, it seems a shame that I'm a bit suspicious of VS2005 which is newer of course.
Basically, any advice would be welcome, this isn't spam or trying to get controversy or arguments, nor do I really need any cryptic replies like "use what you feel most comfortable with". I'm at a point where I really can think about where to invest a bit of time and self learning and start playing around. If someone can tell me about other IDE's or perhaps quell my fears about VS2005 in Vista (I even read that you need Vista Business - not sure which I have, but I don't have the most expensive version, nor the cheapest) then perhaps I'm Ok just carrying on with simple dialog apps in MFC for now, but am I missing the boat here, is C# and .NET taking over?
|
|
|
|
|
ldsdbomber wrote: or trying to get controversy or arguments, nor do I really need any cryptic replies like "use what you feel most comfortable with"
Unfortunately, all you're going to get are opinions.
Research the options and decide what's best for you!
I personally would not use VC6 anymore if you have VS 2005.
With VS 2005 and beyond you'll have many more options in one package,
include improved MFC, improved C++ compiler, C++/CLI, C#, ...
But that's just my opinion.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
opinions are fine and thanks for yours. I'm sure I did install some kind of 'patch' for Vista but remember that it didn't seem to fix all my issues relating to adding control variables to controls and things like that. I've seen there is a 430 MB VS 2005 SP1 Team Update(what????) and a Vista SP1 Update at 29MB, not sure if they are both part of the same process, I'll see if I can find what it was I installed when i first got the laptop, probably summertime 2007.
cheers!
|
|
|
|
|
Oops I forgot about you mentioning VS2005 not working well on Vista...
It should work fine, so something (obviously) is wrong...
I would recommend installing the VS2005 SP1 for sure. Yes, it is huge - pretty much replaces most of VS haha.
Also, if running your apps from the VS debugger, try running VS as an administrator
if not doing so already (this is no longer required in VS 2008).
Cheers,
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|