|
Did you install the latest Platform SDK? VirtualAllocEx should be defined in winbase.h which is included by windows.h.
DWORD Address;
to
LPVOID Address;
Address == VirtualAllocEx(
to
Address = VirtualAllocEx(
|
|
|
|
|
Thx for your replay. I got rid of the two warnings but am still stuck with the error (error C3861: 'VirtualAllocEx': identifier not found, even with argument-dependent lookup). I have vertion Microsoft Visual C++ .NET. Eny more advice??? please??? thx Glich
|
|
|
|
|
From MSDN:
Requires Windows Vista, Windows XP, Windows 2000 Professional, or Windows NT Workstation 4.0.
Server Requires Windows Server "Longhorn", Windows Server 2003, Windows 2000 Server, or Windows NT Server 4.0
That means you need to set WINVER macro to a version that would include VirtualAllocEx declaration.
My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.
|
|
|
|
|
Thx for your help.
I have tryed it with: "#define WINVER 0x0400" as http://msdn2.microsoft.com/en-us/library/6sehtctf.aspx
suggests but there is no diference. these are my command line options: "/D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Gm /EHsc /RTC1 /MLd /Yu"stdafx.h" /Fp"Debug/InjProg.pch" /Fo"Debug/" /Fd"Debug/vc70.pdb" /W3 /nologo /c /Wp64 /ZI /TP" and these are my linker command line options: "/OUT:"Debug/InjProg.exe" /INCREMENTAL /NOLOGO /DEBUG /PDB:"Debug/InjProg.pdb" /SUBSYSTEM:CONSOLE /MACHINE:X86 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib"
eny help to help me? thx!
|
|
|
|
|
glich wrote: I have tryed it with: "#define WINVER 0x0400"
Where did you put this definition? It must be defined before windows.h is included. If you use precompiled headers, it is best to put it at the top of stdafx.h. Or just add it to the Project settings.
My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.
|
|
|
|
|
Thx for your replay.
It still does not work even after I placed the line "#define WINVER 0x0400" as the first line.
More help is needed if posible. Thx again.
|
|
|
|
|
Actually, it _WIN32_WINNT that has to be 0x0400. WINVER 0x0400 is the code for windows 95.
#define _WIN32_WINNT 0x0400
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
adfasdf
Pravin Parmar,
PravinParmar.ce@gmail.com
|
|
|
|
|
i want to check thread is running state or not and if it is running then terminate this thread and start another thread.
anybody have idea about this please share with me:its urgent
Bankey Khandelwal
Software Engineer
|
|
|
|
|
To check if thread is still running
<br />
bool IsThreadRunning(HANDLE hThread)<br />
{<br />
DWORD dwExitCode;<br />
::GetExitCodeThread(hThread, &dwExitCode);<br />
return (dwExitCode == STILL_ACTIVE)? true : false;<br />
}<br />
Don't try to terminate the thread using TerminateThread(), either have a flag or event that the thread checks to see if it should terminate gracefully. Frankly I think it's better to reuse the thread...
|
|
|
|
|
To tell if a thread is running or not:
DWORD dwState = WaitForSingleObject(hThread, 0);
switch(dwState)
{
case WAIT_TIMEOUT:
break;
case WAIT_OBJECT_0:
break;
}
The solution using the GetExitCodeThread API has a flaw. From MSDN:
"Warning: If a thread happens to return STILL_ACTIVE (259) as an error code, applications that test for this value could end up in an infinite loop."
In general there is no safe way to forcefully terminate a thread (although this doesn't seem to stop people from doing it) - Doing so, by calling TerminateThread for example, can put the process into an unstable state. One way this happens is as follows:
1. The thread about to be terminated calls an API which enters a critical section by calling EnterCriticalSection .
2. It is terminated before it can call LeaveCriticalSection .
3. Another thread calls the same API and it deadlocks: This API is now broken and any thread calling it will now deadlock.
This really happens and I can tell you from experience that tracking down the problem is not pleasant.
The general solution to this problem is to program the thread so you can arrange for it to exit, typically by signaling an event and then waiting for it to terminate.
Steve
|
|
|
|
|
Ah. I've never noticed that little caveat since I don't usually return anything other than 0 for my threads. Guess you learn something new everyday...
|
|
|
|
|
hfry wrote: I don't usually return anything other than 0 for my threads
Returning ZERO signals thats your thread is successfully closed
|
|
|
|
|
ThatsAlok wrote: Returning ZERO signals thats your thread is successfully closed
This need not be the case: The programmer is free to place whatever interpretation on the exit code of a thread that is appropriate for his application. 0 for success is simply the most popular. For example you could use the return code to return the result of a computation.
Steve
|
|
|
|
|
Stephen Hewitt wrote: For example you could use the return code to return the result of a computation.
yeah right... but generally I return results through custom Window Message, as it halp in teo way .. retuning you result plus signally thread is now closed
|
|
|
|
|
as my understanding, bar (or space) width is based on unit of mil (1/1000 inch), minimum width of a bar is 7.5 mils.
so barcode should be drawn with MM_HIENGLISH MapMode.
I have checked several barcode software, they draw barcode in many ways with different MapMode, my Question is:
which MapMode is better for drawing barcode?
is MM_HIENGLISH better?
thx
A nice hyper tool for optimizing your Microsoft html-help contents.
A best image tool for Windows C++ programmers, don't miss it!.
Includeh10
|
|
|
|
|
I am getting an error as transmission error while sending FAX using the FaxSendDocument() API.
Can anybody tell me what may be going wrong.
Thanks
aasstt
|
|
|
|
|
Hi
I Have created the dialog based application. On one of the dialog i have three buttons and onclick of them i am instantiating chiold dialogs. Now on one of my child dialog i have list control (CListCtrl). I have Put the image on whole child dialog on picture control and on that I have List control. When I runthe application I se all the controls on child dialog and data inside it.
My Problem is that When i increase the size of coloumn i list control the borders dissappear. and when I press "Esc" all the coontrol opn child dialog also dissappears
I look forward to the reply
Cheers
"Peace of mind through Technology"
|
|
|
|
|
Hi Ganesh_T ,
Can you be more specific ( I press "Esc" all the coontrol opn child dialog also dissappears)
And first question (increase the size of coloumn i list control the borders dissappear)
(I think or I suggestion) that you can derived CListCtrl in your program)
|
|
|
|
|
Suppose we have the Dialog as parent and two dialog as child. On click of button which is placed on parent dialog I am displaying first child dialog.
Now when the focus is on the main Dialog means parent dialog I press "Escape" button the controls which are placed on the dialog box dissappears.
I am not able to find out the problem. Well itried doing different things and setting the properties then also it doesn/t worked.
Cheers
"Peace of mind through Technology"
|
|
|
|
|
Hi Ganesh_T ,
Hope I understood your question
I had problem that I created child dialog in main program when I press "Esc" dialog closed
but my controls fix, but this problem that controls are dissappears, I think that usually focus is in window unless you use setfocus
why cthe controls are dissappears?
I use this way
I declare one CDialog and use a variable of cMyDialog in main program
and in child dialog I had controls(button,editbox,...) when I press Esc in child dialog
this disappear but controls not change (I suggestion you check OnCancel)
|
|
|
|
|
Dear Gurus,
I have a question concerning accessing bits from an array of unsigned char .
Considering a series of bytes read from an already coded file that I can't modify because it is coded "like that", I need to exctract the bits of the array in the following way:
consider the values in the file:
0x55 0x55 0x55 0x55 0x55 0x55 0x55 0x55 0x55 0x55
the vector (1D array) of unsigned char contents is the same of the file:
0x55 0x55 0x55 0x55 0x55 0x55 0x55 0x55 0x55 0x55
so, here we have 10 unigned char which is the way it is coded in the file.
Now, in the real visual world, it is in fact a 2D array. in our example, it should be an array of 2 lines and 20 columns! each unsinged char represent 4 cell of the real array these values are sets of 2 bits.
So, in our example, we should have the simple array after accessing the file:
L1: 11111111111111111111
L2: 11111111111111111111
if you take the file value as packet of bits you have:
L1: 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
L2: 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
Now, group these vallues by packets of nibbles:
L1: 0101 0101 0101 0101 0101 0101 0101 0101 0101 0101
L2: 0101 0101 0101 0101 0101 0101 0101 0101 0101 0101
if you convet these values in hexa by nibbles; you have:
L1: 5 5 5 5 5 5 5 5 5 5
L2: 5 5 5 5 5 5 5 5 5 5
And finally if you group these nibbles by bytes you have the array:
L1: 55 55 55 55 55
L2: 55 55 55 55 55
In the file it is coded the way I told just above:
55 55 55 55 55 55 55 55 55 55
So, if you followed, my question is the following:
given the array read from the file (values just above), how can I access to the set of 2 bits???
the function's header looks like this:
int GetAt(unsigned char* compressedArray, int i, int j);
and it should return the cell content.
How to do such a function that read the compressed values????
I hope you understood my problem.
If so, can someone give me a hand shot please?
Best regards.
Fred.
There is no spoon.
-- modified at 3:45 Saturday 25th March, 2006
|
|
|
|
|
I had to read what you had written several times. I gather that you have sets of data which is 2 bits in length (ie. of values 0 to 3)
The following code will get the value of the 2 bits at index i. I don't know what you mean by this being a 2D array. You would probably want to check that nArrayPos doesn't go over the bounds of the compressedArray.
<br />
unsigned char GetAt(unsigned char *compressedArray, int i)<br />
{<br />
int nArrayPos = i / 4;<br />
int nBytePos = (3 - (i % 4)) * 2;<br />
return (compressedArray[nArrayPos] >> nBytePos) & 0x03;<br />
}<br />
If you want to check which bit is set for the result you could always do something like
<br />
if((result & 0x02) == 0x02)
if((result & 0x01) == 0x01)
|
|
|
|
|
Actually, my problem is to decode a collision map wich is "compressed" for an old school 2D game.
It's like I had explained above (values are stored as set of 2 bits) and the values are stored as short in the file, so the values are inverted because of little endian.
For example:
the following line in the map would look like this (here, the width is 20 columns):
1 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 1
In the file, it is coded this way:
0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 1 0 0 0
the "1" means there is a wall, "0" means no wall.
the values are inverted. so I need to reverse them to get the correct decoding.
It drives me crazy
How to do that?
Fred.
There is no spoon.
|
|
|
|
|
It looks like you may have either misrepresented your problem or I have misunderstood. You said that values are stored as a set of 2 bits (which can have 4 values from 0 to 3).. but it looks like it is just 1 bit (with a value of either 0 or 1)?
When doing bitwise operations though, always think of operating on the big-endian representation.
Since Windows is little endian... you can modify the function accordingly. While the values are held as little-endian, the bitwise operations are conceptually done in big-endian so you don't have to logically flip it yourself.
<br />
unsigned char GetAt(unsigned short *compressedArray, int i)<br />
{<br />
int nArrayPos = i / 16;<br />
int nBytePos = (15 - (i % 16));<br />
return (compressedArray[nArrayPos] >> nBytePos) & 0x01;<br />
}<br />
edit: 1 0 0 0 is a short? does that mean it is using 4 bits to represent 1 value of either 0 or 1? Actually that snippet seems to make no sense since ordering is per byte.. so I don't know how 1 0 0 0 gets represented into 0 0 0 1.
-- modified at 12:01 Saturday 25th March, 2006
|
|
|
|