|
Hi Stuart, Let me continue my discussion now. Okay, now as you said, We'd require two threads to release the Semaphore without even acquiring it. Assume we are not doing it. Now the Semaphore variable counter would be 0. What should happen if a new process/thread tries to call CreateSemaphore now?
Should I check for GetLastError()? So that I might get "Limit_reached" or something? Before putting the new handle into Wait function? Or I should pass the handle to the wait function straight and try to get check the value returned by it?
Your answers have been awesome. Thanks a lot.
----------------------------
286? WOWW!
|
|
|
|
|
_8086 wrote: CreateSemaphore
Ummm - it'd create a new semaphore? Or are you creating a named semaphore and using the same name as previously (and if that's the case, the initial and maximum counts are ignored)?
Anyway - CreateSemaphore doesn't matter - it's the wait function[^] that acquires the semaphore. When the semaphore's count is zero, waiting on the semaphore will cause the wait function to block - that's what the documentation[^] says, anyway.
If you use WaitForSingleObject, it will return WAIT_OBJECT_0 if it acquires the semaphore or WAIT_TIMEOUT if the semaphore isn't available (unless you specify a timeout of INFINITE, in which case WaitForSingleObject will never return).
The 'Using Semaphore Objects[^]' page may clarify things.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Stuart Dootson wrote: Ummm - it'd create a new semaphore? Or are you creating a named semaphore and using the same name as previously (and if that's the case, the initial and maximum counts are ignored)?
Yes I've been talking about named semaphores across multiple processes . Also why it init, max counts should be ignored in this case?
Stuart Dootson wrote: If you use WaitForSingleObject, it will return WAIT_OBJECT_0 if it acquires the semaphore or WAIT_TIMEOUT if the semaphore isn't available (unless you specify a timeout of INFINITE, in which case WaitForSingleObject will never return).
Hmm okay now it's clear. I did have a wrong idea. For example, If the initial count = 3, maxcount =5. I thought 3 would get WAIT_OBJECT_ thing, the next 2 Would calls would "successfully-get-blocked" with the wait function. Any other calls after these wouldn't wait successfully. I thought this will also get through the wait function but with some error set in "last-error".
----------------------------
286? WOWW!
|
|
|
|
|
_8086 wrote: Also why it init, max counts should be ignored in this case?
Because the documentation says so[^]
And because it makes a lot of sense for the count parameters to be immutable
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi There,
I am using the following example to make Win32 tab control without using MFC.
Win32 SDK C Tab Control made easy[^]
There are some business reasons that I can only use Win32 API for this.
I am able to create the tab pages. But finding weird behaviour with the messageloop.
I am making an XLL, so my dialog is opened from a selection from Excel menu item.I get a dialog box with tabs on clicking this certain menu item. Each tab has some edit boxes and buttons. which all work fine except the TAB key doesnt work to move from one item to another.
I have implemented it the same way as in above program. The problem i face are:
1. When i click on the tabs, it shows me the correct child dialog. when i change the selection of tab, it goes to the correct next dialog. so everything works fine here. But when i click on any area in the child dialog (i.e to activate the message loop), The tab key starts working on that particular selected tab, BUT after this i am not able to select any other tab. On clickin on any other tab takes me to the first tab (iSel=0)
2. When I close the dialog box from the X button in top right corner; It closes the dialog box BUT it also closes my Excel window which i dont want.
This application I am developing to configure and test some connections. so I need the excel window open after i am done with the configurations.
Please reply if you read this message. I will appreciate any help.
Regards
Ajay
ajaymat@gmail.com
|
|
|
|
|
Hello!
Have anyone tried to draw a Gif on a OpenGL Window?
I´m stuck here...
Thaks!
|
|
|
|
|
Anybody know how to convert the following code?
__asm<br />
{<br />
push eax<br />
push edi<br />
<br />
push es<br />
push ecx<br />
<br />
mov edi, [this]<br />
add edi, [m_StartExceptionContext]<br />
push ds<br />
pop es<br />
mov ecx, size m_StartExceptionContext<br />
xor eax, eax<br />
push edi<br />
cld<br />
rep stosb<br />
pop edi<br />
<br />
pop ecx<br />
pop es<br />
<br />
mov dword ptr [edi] CONTEXT.ContextFlags, CONTEXT_FULL<br />
mov dword ptr [edi] CONTEXT.Eax, eax<br />
mov dword ptr [edi] CONTEXT.Ecx, ecx<br />
mov dword ptr [edi] CONTEXT.Edx, edx<br />
mov dword ptr [edi] CONTEXT.Ebx, ebx<br />
mov dword ptr [edi] CONTEXT.Esi, esi<br />
mov dword ptr [edi] CONTEXT.Edi, edi<br />
mov word ptr [edi] CONTEXT.SegSs, ss<br />
mov word ptr [edi] CONTEXT.SegCs, cs<br />
mov word ptr [edi] CONTEXT.SegDs, ds<br />
mov word ptr [edi] CONTEXT.SegEs, es<br />
mov word ptr [edi] CONTEXT.SegFs, fs<br />
mov word ptr [edi] CONTEXT.SegGs, gs<br />
pushfd<br />
pop [edi] CONTEXT.EFlags<br />
mov eax, [ebp]<br />
mov dword ptr [edi] CONTEXT.Ebp, eax<br />
mov eax, [ebp + 4]<br />
mov dword ptr [edi] CONTEXT.Eip, eax<br />
lea eax, [ebp + 8]<br />
mov dword ptr [edi] CONTEXT.Esp, eax<br />
<br />
pop edi<br />
pop eax<br />
}<br />
}
|
|
|
|
|
If that code works, why bother? The assembly code is x86 specific, the necessary intrinsics would be x86 specific as well as being Visual C++ specific - you won't get any cross-platform benefit.
For what that code's doing (looks like it's throwing an exception, whilst storing the full processor context, possibly so it can resume?), I suspect you need assembly language, 'cos the compiler would add in too much unwanted rubbish.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I need it to compile to an x64 Architecture!! As far as i know VS2005 does not support any inline code (Assembler)..
|
|
|
|
|
Not when compiling 64bit code no.. but AFAIK not all the instructions you used are available as intrinsic functions - actually, most aren't.
The only solution I know is using an other compiler..
|
|
|
|
|
You probably need to do more than just literally translate that code, then - the processor context for the x64 will be different (for example, the 64-bit register set is different) than the x86 context. Have a look at this page on x64 calling conventions[^] - that's very different to x86.
Your best bet might be to rewrite the code as a standalone assembly language file that you can assemble with MASM and then link into your application (that's the easiest way to make sure it works, as you have no compiler bits getting in the way) then use that as a working model to attempt to convert into intrinsics.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
|
I'm using VS2008 Team System. How do I add a web reference to my C++ project?
|
|
|
|
|
Google[^] -> here[^]
You can only add a web reference for a C++/CLR project, not an unmanaged C++ project.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
In VS2005, I used to right click and choose "Add Web Reference". In VS2008, that menu is disabled. Any way to enable it?
|
|
|
|
|
That menu is enabled for me in VS2008 when I have a C++/CLR project. If it's not enabled for you in VS2008 for a C++/CLR project, that says to me that your Visual Studio installation is broken.
The reason Add Web Reference no longer works for unmanaged C++ projects in VS2008 is that ATL Server isn't in VS2008[^]. A simple Google[^] would have shown you that.
You can download ATL Server from CodePlex[^] - it's been open sourced. This includes sproxy.exe, which will generate the C++ wrapper code for the web-service.
The other Microsoft alternative is the Windows Web Services[^], which will be released with Windows 7 and available as an update for Windows XP SP2 and later.
An open-source alternative is gSOAP[^].
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
i think the MFC or unmanaged is means .
how can we add in this kind of project
|
|
|
|
|
In MSDN:
Notifies a service that its startup parameters have changed. The hService handle must have the SERVICE_PAUSE_CONTINUE access right.
Does this mean that I don't need to care about the sync problem between the ControlHandler and ServiceMain function?
|
|
|
|
|
maishuiking wrote: Does this mean that I don't need to care about the sync problem between the ControlHandler and ServiceMain function?
I haven't got a fricking clue and, I suspect, neither will most people on this forum without a little more context describing what you're talking about when you maention "the sync problem".
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I want to change the cursor of my mouse when ever i point it on a button or on a static text. Please let me know can that be done???
Thanks in Advance
|
|
|
|
|
subclass the button or the static window and use SetCursor to change the shape of the cursor when the mouse is over the control see WM_MOUSEMOVE message for the same.
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
Rather than handling WM_MOUSEMOVE , as suggested by _AnsHUMAN_ 's answer, you probably want to handle WM_SETCURSOR [^]
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi all,
How to change the environment variable(esp. PATH) setting using
C++ code.
|
|
|
|
|
|
#include "stdafx.h"
#include <cstdlib>
int _tmain(int argc, _TCHAR* argv[])
{
std::system("set pathTEST=d:");
std::system("set p");
return 0;
}
|
|
|
|