|
hi all i want to get the cpu idle item when user is performing now activities on bases of which the screen saver runs etc means when user is performing no activities then the screen saver runs.
Thanks in Advance.
Tasleem Arif
|
|
|
|
|
|
|
Thank u both for answering
Tasleem Arif
|
|
|
|
|
youre welcome .
|
|
|
|
|
hi i want to crreate a udp application for that i created a dialog based project with windows socket support
in that BOOL CUDPclientDlg::OnInitDialog(){} method i have written
m_client.Create(SOCK_DGRAM);<br />
m_client.Connect("localhost",2000);
after that i create a button in that function i have written
m_client.Send("hi",strlen("hi"));
for receiveing my message in the server i am not receiveing this message.how to keep the server in listen state under the udp?
-- modified at 0:55 Friday 25th August, 2006
|
|
|
|
|
hi,
see the code .
//==========================================================================
Client Code ---->
#include <winsock2.h>
#include <ws2tcpip.h>
#include <stdlib.h>
#include <stdio.h>
#define DEFAULT_BUFLEN 512
#define DEFAULT_PORT "27015"
int main(int argc, char **argv)
{
WSADATA wsaData;
SOCKET ConnectSocket = INVALID_SOCKET;
struct addrinfo *result = NULL,
*ptr = NULL,
hints;
char *sendbuf = "this is a test";
char recvbuf[DEFAULT_BUFLEN];
int iResult;
int recvbuflen = DEFAULT_BUFLEN;
// Validate the parameters
if (argc != 2) {
printf("usage: %s server-name\n", argv[0]);
return 1;
}
// Initialize Winsock
iResult = WSAStartup(MAKEWORD(2,2), &wsaData);
if (iResult != 0) {
printf("WSAStartup failed: %d\n", iResult);
return 1;
}
ZeroMemory( &hints, sizeof(hints) );
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP;
// Resolve the server address and port
iResult = getaddrinfo(argv[1], DEFAULT_PORT, &hints, &result);
if ( iResult != 0 ) {
printf("getaddrinfo failed: %d\n", iResult);
WSACleanup();
return 1;
}
// Attempt to connect to an address until one succeeds
for(ptr=result; ptr != NULL ;ptr=ptr->ai_next) {
// Create a SOCKET for connecting to server
ConnectSocket = socket(ptr->ai_family, ptr->ai_socktype,
ptr->ai_protocol);
if (ConnectSocket == INVALID_SOCKET) {
printf("Error at socket(): %ld\n", WSAGetLastError());
freeaddrinfo(result);
WSACleanup();
return;
}
// Connect to server.
iResult = connect( ConnectSocket, ptr->ai_addr, (int)ptr->ai_addrlen);
if (iResult == SOCKET_ERROR) {
closesocket(ConnectSocket);
ConnectSocket = INVALID_SOCKET;
continue;
}
break;
}
freeaddrinfo(result);
if (ConnectSocket == INVALID_SOCKET) {
printf("Unable to connect to server!\n");
WSACleanup();
return 1;
}
// Send an initial buffer
iResult = send( ConnectSocket, sendbuf, (int)strlen(sendbuf), 0 );
if (iResult == SOCKET_ERROR) {
printf("send failed: %d\n", WSAGetLastError());
closesocket(ConnectSocket);
WSACleanup();
return 1;
}
printf("Bytes Sent: %ld\n", iResult);
// shutdown the connection since no more data will be sent
iResult = shutdown(ConnectSocket, SD_SEND);
if (iResult == SOCKET_ERROR) {
printf("shutdown failed: %d\n", WSAGetLastError());
closesocket(ConnectSocket);
WSACleanup();
return 1;
}
// Receive until the peer closes the connection
do {
iResult = recv(ConnectSocket, recvbuf, recvbuflen, 0);
if ( iResult > 0 )
printf("Bytes received: %d\n", iResult);
else if ( iResult == 0 )
printf("Connection closed\n");
else
printf("recv failed: %d\n", WSAGetLastError());
} while( iResult > 0 );
// cleanup
closesocket(ConnectSocket);
WSACleanup();
return 0;
}
//===========================================================================
//===========================================================================
----> server code
#include <winsock2.h>
#include <ws2tcpip.h>
#include <stdlib.h>
#include <stdio.h>
#define DEFAULT_BUFLEN 512
#define DEFAULT_PORT "27015"
int __cdecl main(void)
{
WSADATA wsaData;
SOCKET ListenSocket = INVALID_SOCKET,
ClientSocket = INVALID_SOCKET;
struct addrinfo *result = NULL,
hints;
char recvbuf[DEFAULT_BUFLEN];
int iResult,
recvbuflen = DEFAULT_BUFLEN;
// Initialize Winsock
iResult = WSAStartup(MAKEWORD(2,2), &wsaData);
if (iResult != 0) {
printf("WSAStartup failed: %d\n", iResult);
return 1;
}
ZeroMemory(&hints, sizeof(hints));
hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP;
hints.ai_flags = AI_PASSIVE;
// Resolve the server address and port
iResult = getaddrinfo(NULL, DEFAULT_PORT, &hints, &result);
if ( iResult != 0 ) {
printf("getaddrinfo failed: %d\n", iResult);
WSACleanup();
return 1;
}
// Create a SOCKET for connecting to server
ListenSocket = socket(result->ai_family, result->ai_socktype, result->ai_protocol);
if (ListenSocket == INVALID_SOCKET) {
printf("socket failed: %ld\n", WSAGetLastError());
freeaddrinfo(result);
WSACleanup();
return 1;
}
// Setup the TCP listening socket
iResult = bind( ListenSocket, result->ai_addr, (int)result->ai_addrlen);
if (iResult == SOCKET_ERROR) {
printf("bind failed: %d\n", WSAGetLastError());
freeaddrinfo(result);
closesocket(ListenSocket);
WSACleanup();
return 1;
}
freeaddrinfo(result);
iResult = listen(ListenSocket, SOMAXCONN);
if (iResult == SOCKET_ERROR) {
printf("listen failed: %d\n", WSAGetLastError());
closesocket(ListenSocket);
WSACleanup();
return 1;
}
// Accept a client socket
ClientSocket = accept(ListenSocket, NULL, NULL);
if (ClientSocket == INVALID_SOCKET) {
printf("accept failed: %d\n", WSAGetLastError());
closesocket(ListenSocket);
WSACleanup();
return 1;
}
// No longer need server socket
closesocket(ListenSocket);
// Receive until the peer shuts down the connection
do {
iResult = recv(ClientSocket, recvbuf, recvbuflen, 0);
if (iResult > 0)
printf("Bytes received: %d\n", iResult);
else if (iResult == 0)
printf("Connection closing...\n");
else {
printf("recv failed: %d\n", WSAGetLastError());
closesocket(ClientSocket);
WSACleanup();
return 1;
}
} while (iResult > 0);
// Echo the buffer back to the sender
iResult = send( ClientSocket, recvbuf, iResult, 0 );
if (iResult == SOCKET_ERROR) {
printf("send failed: %d\n", WSAGetLastError());
closesocket(ClientSocket);
WSACleanup();
return 1;
}
printf("Bytes Sent: %ld\n", iResult);
// shutdown the connection since we're done
iResult = shutdown(ClientSocket, SD_SEND);
if (iResult == SOCKET_ERROR) {
printf("shutdown failed: %d\n", WSAGetLastError());
closesocket(ClientSocket);
WSACleanup();
return 1;
}
// cleanup
closesocket(ClientSocket);
WSACleanup();
return 0;
}
//=========================================================================
there is every thing in msdn just learn how to use the Socket.
Think Clever
Uday kiran
|
|
|
|
|
uday kiran janaswamy wrote: there is every thing in msdn just learn how to use the Socket.
Think Clever
useing Asynksocket i want to create a datagram server.which methods i have to use
|
|
|
|
|
hi,
dont use
m_client.Send("hi",strlen("hi")); //not UDP it for TCP.
m_client.Sendv(...) // may be you check MSDN for UDP.
Uday kiran
|
|
|
|
|
uday kiran janaswamy wrote: m_client.Sendv(...) // may be you check MSDN for UDP.
hi,
i know it ,but here m_client is the variable of type Cclient which i have derived from the AsynkSocket.
but in that onley send method is there i have nt found listen,recv,Senddv like methods.
|
|
|
|
|
hi
i am new to driver .
i want develop virtual printer such that
it convert that page to image file
how can i started for that
for that can i have some sample code ?
is there any code available in DDK src?
pradip
pradip patel -SE
|
|
|
|
|
Can you be more specific about convert page to image
|
|
|
|
|
Hello,
I use this fonction to close and destroy a modeless dialogbox but it crash my application :
m_Dlg* dialogbox CDialog created by new ..
if (m_Dlg!=NULL) {
m_Dlg->DestroyWindow();
delete m_Dlg;
m_Dlg=NULL;
}
Should i use realy delete after destroy ?
It works some time but it crash many time !
Thank you
AutreChien
|
|
|
|
|
NorGUI wrote: f (m_Dlg!=NULL) {
m_Dlg->DestroyWindow();
Send WM_QUIT message before deleting the Dialog instead of DestroyWindow!,
also check for existence of DialogWindow before cleaning up task!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
I'm new to VC++. WM_QUIT doc says it will quit app. Should we use it for one window?
----------------------
Mayank Thakore
Learning C++ - since 1998
They didn't print my card right; so I resigned.
|
|
|
|
|
MayankT wrote: what is the diff between WM_DESTROY and DestroyWindow?
according to MSDN DestoryWindow api also send WM_NCDESTROY to window to deactivate it!
MayankT wrote: Mayank Thakore
Learning C++ - since 1998
cool!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
MayankT wrote: WM_QUIT doc says it will quit app
A correction, it will stop message loop, not actually quit the window!. if you have put any wait function after the MessageLoop.. your window might get destroyed but your application still visible in running process list!
have a look sample app!
WinMain(....)
{
..........
GetMessage(&Msg,0,0,0)
{
}
.........
// WM_QUIT will break above loop but what about WaitForSingleObject written below!
WaitForSingleObject(...)
}
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
|
are you destroying window created by some other thread? in that case DestroyWindow will not work. Did it crash in DestroyWindow or delete?
----------------------
Mayank Thakore
Learning C++ - since 1998
They didn't print my card right; so I resigned.
|
|
|
|
|
I found my problem it was that I called the from Parent Window
dlg->DestroyWindow;
and
delete dlg;
but in my class CDialog it was in
void Dlg::PostNcDestroy()
{
CDialog::PostNcDestroy();
delete this;
}
thank you it was a big mistake from me
AutreChien
|
|
|
|
|
NorGUI wrote: if (m_Dlg!=NULL) {
m_Dlg->DestroyWindow();
delete m_Dlg;
m_Dlg=NULL;
}
There should not be any problem with this code. Can you tell, where crash taking you in the code.
There must be something other , you are doing wrong.
|
|
|
|
|
It appears that the NT Security protocol is designed to allow or deny access to files in directories, depending on the security clearance of the human user. I have an application, where access would have to be be decided on, not only by human user identity, but also by means of the identity of the application used to access the data. ( e.g. a User must be stopped from opening a file via NotePad, but, may have access through a Bespoke Application) For instance, Banking Software would have to contain a lot of this. Does Anyone have any Idea or observations about this
regards
LateNightsInNewry
|
|
|
|
|
|
I'm printing this just off now, but scanning it I got the gist. It appears to be an obvious requirement that Bill gates never thought about! he seems to be pre-occupied with someone getting access to someone else's ascii file, or something that those like CIA could read from a disk they recovered.
About that,I can assure everybody that Bill has been quite successfull, in that a known local forger in my local area was set free from proceedings in such matters as providing forged passports, solely, because after two years GCHQ ( The UK Gouvernments Central Code Breaking Institute)in the UK failed to decript the man's hard disk, and the courts ran out of patience. The good news out of this is, that Encryption doe seem to work! The bad news is, it only seems to work in Microsoft ways!
LateNightsInNewry
|
|
|
|
|
I'm trying to make my code ANSI, MBCS and UNICODE compatible. All my string literals are wrapped in the _T() macro, and I use all the TCHAR functions when dealing with strings. In ANSI and MBCS my code compiles fine, but when switching to UNICODE I get compile errors. I have defined both UNICODE and _UNICODE. Here is an example:
'CreateFontA' : cannot convert parameter 14 from 'unsigned short [16]' to 'const char *'
and the function:
hfont = CreateFont(lfheight,0,0,0,800,FALSE,0,0,0,0,0,0,0,_T("Times New Roman") );
This tells me the ANSI version is trying to convert a wide char. Yet in the same file:
'wcsstr' : none of the 2 overloads can convert parameter 1 from type 'char *'
and the function:
TCHAR *idx = _tcsstr(tmp,_T("\\n"));
which tells me the functions are the unicode version.
Whats going on?
-- modified at 20:02 Thursday 24th August, 2006
|
|
|
|
|