|
Umm... thats not what I meant. For example, the dbghelp.h that ships with VS2005's PSDK uses PSTR for the first param of PENUMLOADED_MODULES_CALLBACK64 while the dbghelp.h that ships with SDK6.1 uses PCSTR. Now, I want both who does and doesn't have SDK6.1 to be able to compile the app. Hopefully this makes things a bit clear.
--
Regards,
-Tareq
|
|
|
|
|
Ah, right - hadn't noticed that before. Not quite as obvious as all the __in things on function parameters
Now, looking at the SDK headers (v6.0A), they use the macro CONST to add const-ness to SDK parameter specs.
So, you could do something like:
#include <Windows.h>
#ifndef CONST
#define CONST
#endif
and then use CONST instead of const ?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thanks for spending some time on this... unfortunately, the PSDK that comes with VC++2005 does the same with CONST. So it will have the same effect regardless of SDK6.0+.
-Tareq
|
|
|
|
|
Hello,
I use the following to detect the version of Platform SDK/Windows SDK.
#include "ntverp.h"
#if !defined(VER_PRODUCTBUILD) || VER_PRODUCTBUILD < 3790
#pragma message ("********************************************"
#pragma message ("Error: You need the latest Microsoft Platform SDK to compile this project.")
#pragma message ("********************************************"
#endif
There are other constants defined in the header which may be of use to you. I believe my preprocessor directives above simply check that VER_PRODUCTBUILD is at minimum Platform SDK for Microsoft Windows Server 2003. There is another constant VER_PRODUCTBUILD_QFE which I *think* can determine patches and service packs.
Best Wishes,
-David Delaune
|
|
|
|
|
ah... just what I was looking for. Thanks .
-Tareq
|
|
|
|
|
I don't like how, in a Windows environment, upon resetting the focus on a minimized window or having the window perform some other complex operation, the thread may stall (temporarily hang, not translating any messages). What if I want to break these operations?
Isn't it possible to spawn a new thread at initialization that either:
1)Solely searches the message queue for WM_QUIT and sets a global flag when triggered. Somehow, before performing any resource and time intensive operations (that might cause a small hang), any function calls check for the flag and break if it is present.
2)Or maybe have the entire message pump in the new thread, as a busy program isn't even able to receive messages while performing operations.
I think the biggest problems would be:
1)Having a separate thread pump messages from the parent
2)Figuring out how to break operations when the WM_QUIT flag (which was set in another thread) is set
Any input, tips, thoughts, examples that might help me?
Thanks, The Scientist.
|
|
|
|
|
It's a good idea - but you've got the conclusion backwards. You put the busy work in a different thread, leave the main (UI) thread alone. Look up worker threads[^].
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I'm a little new to multi-threading.
Isn't there an issue regarding threads and access to process-wide variables/data?
Will I be able to kill a thread, while its in the middle of doing some kind of processing, from the main thread? And can I change the flag's status (if quit is posted after I initialize the new thread)?
|
|
|
|
|
TheScientistIsDead wrote: Isn't there an issue regarding threads and access to process-wide variables/data
Oh yeah - you've got to be very careful. The general rule is that you read things like ints (i.e. 4 bytes or less) without synchronisation, but everything else needs to be synchronised, really.
TheScientistIsDead wrote: Will I be able to kill a thread, while its in the middle of doing some kind of processing, from the main thread?
There is TerminateThread[^], but its use is discouraged.
TheScientistIsDead wrote: And can I change the flag's status (if quit is posted after I initialize the new thread)
Yes. In your WM_QUIT handler, I'd do something like this:
InterlockedExchange(&lQuit, 1);
::WaitForSingleObject(hThread, INFINITE);
and in the worker thread function:
if (lQuit) ExitThread(0);
if (lQuit) ExitThread(0);
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
TheScientistIsDead wrote: I'm a little new to multi-threading.
Then you should read this[^].
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Hello. I am trying to set a REG_MULTI_SZ value. I got 2 values which should be sat. Here is my code:
DWORD dwSize = ((strlen(valueA) + strlen(valueB)) + 3);
PBYTE fValue = (BYTE *)malloc(dwSize * sizeof(DWORD));
memset(fValue , 0, dwSize);
memcpy(fValue , valueA, strlen(valueA) + 1);
memcpy(fValue + strlen(valueA) + 1, valueB, strlen(valueB) + 1);
RegSetValueEx(hk, TEXT("SomeKey"), 0, REG_MULTI_SZ, (LPBYTE) fValue ,(DWORD) dwSize);
<pre>
This code works perfect on windows xp, but crashes on Vista. Actually, it crashes each third time i run my app, but what for sure, it does not set my value at all. (It sets value and returns STATUS_SUCCESS only in one case - if i run my app in context of visual studio debugger - after compilation, i click -> Debug-> Start Debugging). Now, after it's crash i click debug and it points me to malloc.c, at this part:
<pre>
void * __cdecl _malloc_base (size_t size){
void *res = NULL;
// validate size
if (size <= _HEAP_MAXREQ) {
for ( ;; ) {
// allocate memory block
res = _heap_alloc(size); // <-- here
Exactly the same scenario, like above, appears with usage of RtlAllocateHeap:
PBYTE fValue = (BYTE *)RtlAllocateHeap(NtGetProcessHeap(),HEAP_ZERO_MEMORY,dwSize * sizeof(DWORD));
And my question is, does anyone know why or ever encountered such issue? Thanks in advance.
|
|
|
|
|
Are you doing a UNICODE build?
csrss wrote: PBYTE fValue = (BYTE *)malloc(dwSize * sizeof(DWORD));
What is the purpose of sizeof(DWORD) ?
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]
|
|
|
|
|
Thanks, good point
Actually, i have solved the problem by getting rid of malloc function, no idea why it crashes, maybe i dont know how to use it properly, here is the solution :
#define NtGetProcessHeap() (NtCurrentTeb()->PebBaseAddress->DefaultHeap)
char valueA = { 0x56, 0x61, 0x6c, 0x75, 0x65, 0x41, 0x00};
char valueB = { 0x56, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x00};
DWORD dwSize = ((strlen(valueA) + strlen(valueB)) + 3);
LPBYTE fValue = (BYTE *)RtlAllocateHeap(NtGetProcessHeap(),0,dwSize);
memset(fValue , 0, dwSize);
memcpy(fValue , valueA, strlen(valueA) + 1);
memcpy(fValue + strlen(valueA) + 1, valueB, strlen(valueB) + 1);
RegSetValueEx(hk, TEXT("somekey"), 0, REG_MULTI_SZ, (LPBYTE) fValue ,(DWORD) dwSize);
RtlFreeHeap(NtGetProcessHeap(), 0, fValue );
|
|
|
|
|
I believe it has nothing to do with malloc , anyway, I'm just poor old-fashioned C developer...
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]
|
|
|
|
|
I'm porting a WindowsControlLibrary solution from DotNet2003 to 2005 and I get the following error
Error 1 error C2691: 'Mcs600CTL::Mcs600CTLControl::flotArray' : a managed array cannot have this element type c:\work\net2005\mcs600ctl\Mcs600CTLControl.h 148
this use to compile on 2003 without any problems
typedef float flotArray __gc[];
public: __event void Mcs600_Raw_Spektra_Ready( flotArray mySpektra); line 148
I also get this error
Error 2 error C2664: 'Mcs600CTL::Mcs600CTLControl::raise_Mcs600_Raw_Spektra_Ready' : cannot convert parameter 1 from 'float __gc[]' to 'Mcs600CTL::Mcs600CTLControl::flotArray __gc[]' c:\work\net2005\mcs600ctl\Mcs600CTLControl.h 1002
__raise Mcs600_Raw_Spektra_Ready(sampleSpectrum); Line 1002
regards,
-dan
|
|
|
|
|
This is not the correct forum, try the managed C++[^] forum instead.
|
|
|
|
|
I know you are new to CodeProject but you won't find much support for your behavior here. If you want these people to help you (using their time freely) you better get your act together.
|
|
|
|
|
how to use TripleDES algorithm in Visual C++? I observed through the net but did not get exactly working sample using TripleDES ECB mode (2 keys)? Please help me
|
|
|
|
|
|
Hello,
I do not want the border of the childframe which is on the sides of the child window and the upper frame of the child window.But I dont see the identifier which will remove it.How do I create a childframe without borders.
CMDIFrameWnd* pFrame = STATIC_DOWNCAST(CMDIFrameWnd,AfxGetApp()->m_pMainWnd);
if(!Create(NULL, FrameName,WS_VISIBLE | WS_CHILD |
WS_OVERLAPPEDWINDOW ,CRect(0,0,0,0), pFrame, NULL))
{
TRACE0("Failed to create view window\n");
return false;
}
Priya
|
|
|
|
|
From winuser.h :
#define WS_OVERLAPPEDWINDOW (WS_OVERLAPPED | \
WS_CAPTION | \
WS_SYSMENU | \
WS_THICKFRAME | \
WS_MINIMIZEBOX | \
WS_MAXIMIZEBOX)
Note: WS_THICKFRAME is in there...
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Hello,
Thanks for your reply.
even with these identifiers WS_VISIBLE | WS_CHILD | WS_OVERLAPPED I am getting a thick frame
Which ones should I use?
Prithaa
|
|
|
|
|
Hi.
I'm currently working on a game where I do some simple pixel modifications when loading graphics. What I tried to do was to build a function that could take two RGBA values and add them, but I'm having real trouble with the alpha values. I know how to do it when using only RGB colors but when including alpha everything gets much trickier. I would like to have a function like this:
u32 blendPixel(u32 baseColor, u32 paintColor) {
u8 baseRed = getRed(baseColor);
u8 baseGreen = getGreen(baseColor);
u8 baseBlue = getBlue(baseColor);
u8 baseAlpha = getAlpha(baseColor);
u8 paintRed = getRed(paintColor);
u8 paintGreen = getGreen(paintColor);
u8 paintBlue = getBlue(paintColor);
u8 paintAlpha = getAlpha(paintColor);
u8 newRed = ???
u8 newGreen = ???
u8 newBlue = ???
u8 newAlpha = ???
return makecol(newRed, newGreen, newBlue, newAlpha);
}
|
|
|
|
|
Assuming 0 = no colour, 1 = lots of it, and 0=see through, and 1=opaque...
I'd say something like this:
newRed = ( baseAlpha * baseRed + paintAlpha * paintRed ) / (baseAlpha + paintAlpha);
newGreen = ...
newBlue = ...
newAlpha = 1 - (1-baseAlpha)*(1-paintAlpha);
I didn't add in a check whether both paintAlpha and baseAlpha were 0. In which case, newAlpha is also 0, and the end colour is "undefined". Or irrelevant!
I'll leave the challenge of converting my 0.0-1.0 sums to 0-255 to you!
Iain.
In the process of moving to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), give me a job!
|
|
|
|
|
I don't think that method is completly correct.. Calculation of new alpha seems to be right, but not the colors.
If you have a pixel with RGBA value (1, 0, 0, 1) = Red pixel 100% opaque
Then you paint it over with RBGA value (0, 1, 0, 1) = Green pixel 100% opaque
You should end up with a (0, 1, 0, 1) pixel, but you get (0.5, 0.5, 0, 1) = Semi Red/Green 100% opaque
Also tried following base color (1, 0, 0, 0.5) = Red pixel 50% opaque
Painted over with color (0, 1, 0, 0.5) = Green pixel 50% opaque
You should en up with a (0.33, 0.67, 0, 0.75) pixel, but you get (0.5, 0.5, 0, 0.75)
My reference points are from how Paint.NET and Photoshop handle pixels with alpha.
|
|
|
|
|