moifort posteets tagged C  [ Profile ]

Sort by: Date / Title /

  1. 11 years ago
    1. // Declaration socket
    2. WSADATA WSAData;
    3. SOCKET sock;
    4. SOCKADDR_IN sin;       
    5.  
    6. // Initialisation socket
    7. WSAStartup(MAKEWORD(2,0), &WSAData);
    8.  
    9. sin.sin_addr.s_addr= inet_addr("127.0.0.1"); // Adresse IP
    10. sin.sin_family= AF_INET;
    11. sin.sin_port= htons(4001)// Port
    12. sock = socket(AF_INET,SOCK_STREAM,0);
    13. bind(sock, (SOCKADDR *)&sin, sizeof(sin));
    14.  
    15. // Si connection etablie
    16. if (connect(sock, (SOCKADDR *)&sin, sizeof(sin)) == 0)
    17. {
    18. // Declaration socket
    19. WSADATA WSAData;
    20. SOCKET sock;
    21. SOCKADDR_IN sin;       
    22.  
    23. // Initialisation socket
    24. WSAStartup(MAKEWORD(2,0), &WSAData);
    25.  
    26. sin.sin_addr.s_addr     = inet_addr("127.0.0.1"); // Adresse IP
    27. sin.sin_family    = AF_INET;
    28. sin.sin_port        = htons(4001)// Port
    29. sock = socket(AF_INET,SOCK_STREAM,0);
    30. bind(sock, (SOCKADDR *)&sin, sizeof(sin));
    31.  
    32. // Si connection etablie
    33. if (connect(sock, (SOCKADDR *)&sin, sizeof(sin)) == 0)
    34. else
    35.  
    36. // Fin
    37. closesocket(sock);
    38. WSACleanup();
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/392"></script>
  2. 11 years ago
    1. // Fonction pour redemarrer Windows avec les MFC
    2.  
    3. void RestartWindows(void)
    4. {
    5.         // Declaration
    6.         HANDLE hToken;
    7.         TOKEN_PRIVILEGES tkp;
    8.  
    9.         // Get a token for this process.
    10.         OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken);
    11.  
    12.  
    13.         // Get the LUID for the shutdown privilege. 
    14.         LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME,&tkp.Privileges[0].Luid);
    15.  
    16.         tkp.PrivilegeCount = 1// one privilege to set   
    17.         tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
    18.  
    19.         // Get the shutdown privilege for this process. 
    20.         AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES)NULL, 0);
    21.  
    22.  
    23.         // Shut down the system and force all applications to close. 
    24.         ExitWindowsEx(EWX_REBOOT| EWX_FORCE, 0);
    25. }
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/377"></script>

First / Previous / Next / Last / Page 1 of 1 (2 posteets)