|
followait wrote: result = MsgWaitForMultipleObjects(cnt,h, TRUE,INFINITE,QS_ALLINPUT); if (result==(WAIT_OBJECT_0)) { //never get here
try FALSE in the third parameter, bWaitAll
|
|
|
|
|
It's ok.
But I have several threads to be waited, how to do?
Thanks.
|
|
|
|
|
MsgWaitForMultipleObjects takes array of handles
|
|
|
|
|
But when fWaitAll is FALSE , how to ensure all the threads complete?
manually?
|
|
|
|
|
May be by adjusting the array and count of thread handles when a thread is signalled.
|
|
|
|
|
Have it done, thanks very much. 
|
|
|
|
|
how to find out admin privelege using CheckTokenMembership
|
|
|
|
|
if you had read the documentation for CheckTokenMembership Function[^] you should have noticed the following
Example Code
The following example shows checking a token for membership in the Administrators local group.
BOOL IsUserAdmin(VOID)
.
.
.
|
|
|
|
|
|
HI!
Is there anyway a client can detect the server ip address in socket programming instead of hardcoding the ip address like i do e.g. Cservice.sin_addr.s_addr = inet_addr("131.181.98.71");
cheers
|
|
|
|
|
ADTC# wrote: Is there anyway a client can detect the server ip address
No, not if the server is on another host. If it is on the same host you can use the loopback adress 127.0.0.1 , in any other case you need to tell the socket where to connect to. It's probably best to make this configurable in your application.
/M
|
|
|
|
|
If you know the machine name, you can use something like getaddrinfo to translate from a name to an IP.
Judy
|
|
|
|
|
hi back again!
#include<winsock2.h><br />
#include <stdio.h><br />
int main(int argc, char *argv[])<br />
{<br />
HOSTENT *h;<br />
char *serverip;<br />
if (argc != 2) {
fprintf(stderr,"usage: getip address\n");<br />
exit(1);<br />
}<br />
printf("argv[0]:%s\n",argv[0]);<br />
printf("argv[1]:%s", argv[1]);<br />
h = gethostbyname(argv[1]);<br />
serverip = inet_ntoa(*((struct in_addr *)h->h_addr));<br />
printf("Host name : %s\n", h->h_name);<br />
printf("IP Address : %s\n",serverip);<br />
return 0;<br />
}</stdio.h></winsock2.h>
i was trying to run this code from Beej's web site and its command line so when i input ip address somehow the the hostname and ip address are not displayed on the output screen so i think that the ip address was not stored in the structure HOSTENT. can anyone execute this code and see whats wrong with this.
cheers
|
|
|
|
|
You shouldn't use the returned pointer from gethostbyname() without checking it, it can be NULL. Here is an example source code[^].
Hope it helps.
/M
|
|
|
|
|
How to include the resource file in Static lib?
How to invoke the dialog which is created in above static lib from Application(exe)?
Regards
Mallikarjun
|
|
|
|
|
hi
can u create ur own file extension in vc++ so when u double clicked ur application icon ,it opens in ur application .
thank u
any attachments would be helpful
thanks again 
|
|
|
|
|
Assuming I understood your question correctly, yes.
Steve
|
|
|
|
|
thank u
do u have any idea how can i do this.
i mean create file extension for example ".clo"
again ...thank u
|
|
|
|
|
It seems it's no longer a yes or no question! The following .reg file will make CLO files open with Notepad.exe (it assumes Windows is installed to "C:\Windows"):
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\.clo]
@="clofile"
[HKEY_CLASSES_ROOT\clofile]
@="CLO file"
[HKEY_CLASSES_ROOT\clofile\DefaultIcon]
@="C:\\Windows\\system32\\shell32.dll,-152"
[HKEY_CLASSES_ROOT\clofile\shell]
[HKEY_CLASSES_ROOT\clofile\shell\open]
[HKEY_CLASSES_ROOT\clofile\shell\open\command]
@="C:\\Windows\\System32\\Notepad.exe"
To use this copy it into a text file, rename the extension to ".reg" and run it. This might get you started.
Steve
|
|
|
|
|
lahom wrote: do u have any idea how can i do this.
It was another yes/no question!
Peter
"Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."
|
|
|
|
|
|
Hey guys ..
I have a situation where i need to simulate keyboard input in a (preferably) system friendly way.
I'm writing a user level driver for an usb device that has some keys mapped to some events the device generates. ie ( switch XX goes off , simulate a 'P' being pressed (something like that)) , device wise everything is working ok , i'm getting the info from the device , can write to it in bulk , and change settings on the fly through control ..
Now my problem.
I'm insinuating my keystrokes to the OS through the SendInput , and keyb_event api functions (tried both) .
But i'm runing a virtual KVM switch ( ive tried synergy and am now using multiplicity) which intercepts keyboard input , and sends it through the network to the other connected computers , when i'm working on those screens.. it handles normal keystrokes fine , but the keystrokes i send with the api functions just get ignored by both synergy and multiplicity.
So i was thinking .. do you guys know of a skeleton , or of someone that made minimal alterations to DDK's VHIDMINI driver ... so it behaves like a keyboard , and i can access it from user level and make it send keystrokes..The thing is , i want absolute compatibility on the lowest possible level.. and i'm sure i can't go wrong with a virtual HID there..
I'm sure more than one person has done this by now , and would like to know how they did it..
Or better still , are there more system functions to send keystrokes to the OS except SendInput and keyb_event that are transparent to applications.
Any reply is appreciated
Thank you in advance.
|
|
|
|
|
Its actually strange to me that SendInput() does not work. The only thing I can think of that will block SendInput is using DirectInput in exclusive mode.
This code will command the 8042 port at 60h to emit a keystroke. But only if you use something like PortTalk driver to give your application permission to do raw I/O.
http://www.beyondlogic.org/porttalk/porttalk.htm[^]
Here is the code I have used to emit keystrokes from the 8042 chip on the motherboard. You should know that not all 8042 chips will support this. It should be considered a hack.
VOID SendKey8042(int scancode)
{
_outp(0x64,0xd2);
_outp(0x60,scancode);
SleepWithEvents(33);
_outp(0x64,0xd2);
_outp(0x60,scancode | 0x80);
}
One more thing... the i8042 port only understands keyboard scan codes[^].
Best Wishes,
-David Delaune
|
|
|
|
|
Thank you for this information , I'll have a close look at it and give it a go.
Regards.
|
|
|
|
|
I'm trying to share a C++ DLL between a C++ application and a C# application, but a DLL variable is being reset between invocations. Can anyone suggest what I may be doing wrong?
1. The C++ app calls a DLL function.
2. Then the C++ app starts a C# app (with a system () call) that sets a variable to a nonzero value in the same (?) DLL.
3. The C# app terminates.
4. Then the original C++ app looks at the DLL variable and finds it has been magically "reset" to its original zero value. (?!)
I'm assuming there's only ONE instance of the DLL, which is loaded into memory in Step 1. The DLL variable SHOULD BE nonzero in Step 4, but it's not. Any ideas what's going wrong? Thanks!
|
|
|
|