Пример #1
0
void CKeyborDlg::OnExit()
{    
		XMSGBOXPARAMS xmb;
		//xmb.nTimeoutSeconds  = 3;
		//xmb.nDisabledSeconds = 0;
		xmb.nIdIcon          = 0;
	
 	    //xmb.x = 50;
 	    //xmb.y = 20;
	
		xmb.dwOptions |= XMSGBOXPARAMS::VistaStyle;
	
		if( IDOK == ::XMessageBox(m_hWnd, _T("确定退出Keybor?"), _T("提示"), 
						MB_OKCANCEL | MB_ICONQUESTION, &xmb))
		{
//************************************保存对话框坐标**********************************//
			CString rt1,rt2/*,rt3,rt4*/;
			RECT r;
			GetWindowRect(&r);
			rt1.Format("%d",r.left);
			rt2.Format("%d",r.top);
			///////////////////////////测试主对话框宽度和高度
// 			rt3.Format("%d",r.right-r.left);
// 			rt4.Format("%d",r.bottom-r.top);
// 			MessageBox(rt3,rt4,0);
			WritePrivateProfileStringA("System","PosX",rt1,CAfx::filepath);
			WritePrivateProfileStringA("System","PosY",rt2,CAfx::filepath);
//***************************************************************************************//
			SendMessage(WM_CLOSE);
		}
}
BOOL genKeyPair( PROV_CTX* pProvCtx, KEY_INFO* pKey ){
	if ( pKey->algId != CALG_GOST_SIGN ){
		SetLastError( NTE_BAD_ALGID );
		return FALSE;
	}
	if ( pKey->hKeyInformation == NULL ){
		SetLastError( NTE_BAD_KEY_STATE );
		return FALSE;
	}

	CONTAINER_IRZ *pContainerIRZ = (CONTAINER_IRZ*) pProvCtx->pContainer->hServiceInformation;
	KEY_SIGN_INFO *pKeyInfo = (KEY_SIGN_INFO*) pKey->hKeyInformation;


	// Generate key pair in proper.
	if ( pKeyInfo->pPrKey != NULL || pKeyInfo->pPubKey != NULL ){
		DEBUG( 1, "While generating key pair: Key already exists." );
	}
	if ( !genKeyPair( &pKeyInfo->pPubKey, &(pKeyInfo->pPrKey), &pKeyInfo->params, &pContainerIRZ->rand ) ){
		SetLastError( NTE_FAIL );
		return FALSE;
	}
	
	// Write the key to the token.
	LPSTR szPrKey = new CHAR[PRIVATEKEY_CHAR_LEN+1];
	LPSTR szPubKey = new CHAR[PUBLICKEY_CHAR_LEN+1];
	
	if ( !privateKeyToString( pKeyInfo, szPrKey ) ){
		/* \todo release resources.*/
		SetLastError( NTE_FAIL );
		return FALSE;
	}
	
	if ( !pubKeyToString( pKeyInfo, szPubKey ) ){
		/* \todo release resources.*/
		SetLastError( NTE_FAIL );
		return FALSE;
	}

	WritePrivateProfileStringA( 
		"PRIVATEKEY",
		"PRIVATEKEY",
		szPrKey,
		pContainerIRZ->szToken);

	WritePrivateProfileStringA( 
		"PUBLICKEY",
		"PUBLICKEY",
		szPubKey,
		pContainerIRZ->szToken);

	delete[] szPrKey;
	delete[] szPubKey;

	return TRUE;

}
Пример #3
0
LRESULT CALLBACK NetlinkSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam,
                                        LPARAM lParam)
{
   WCHAR tempwstr[MAX_PATH];
   char tempstr[MAX_PATH];

   switch (uMsg)
   {
      case WM_INITDIALOG:
      {
         SendDlgItemMessage(hDlg, IDC_LOCALREMOTEIP, IPM_SETADDRESS, 0, netlinklocalremoteip);

         sprintf(tempstr, "%d", netlinkport);
         SetDlgItemText(hDlg, IDC_PORTET, _16(tempstr));

         return TRUE;
      }
      case WM_NOTIFY:
     		switch (((NMHDR *) lParam)->code) 
    		{
				case PSN_SETACTIVE:
					break;

				case PSN_APPLY:
               // Local/Remote IP
               SendDlgItemMessage(hDlg, IDC_LOCALREMOTEIP, IPM_GETADDRESS, 0, (LPARAM)&netlinklocalremoteip);
               sprintf(tempstr, "%d.%d.%d.%d", (int)FIRST_IPADDRESS(netlinklocalremoteip), (int)SECOND_IPADDRESS(netlinklocalremoteip), (int)THIRD_IPADDRESS(netlinklocalremoteip), (int)FOURTH_IPADDRESS(netlinklocalremoteip));
               WritePrivateProfileStringA("Netlink", "LocalRemoteIP", tempstr, inifilename);

               // Port Number
               GetDlgItemText(hDlg, IDC_PORTET, tempwstr, MAX_PATH);
               WideCharToMultiByte(CP_ACP, 0, tempwstr, -1, tempstr, MAX_PATH, NULL, NULL);
               netlinkport = atoi(tempstr);
               WritePrivateProfileStringA("Netlink", "Port", tempstr, inifilename);

          		SetWindowLong(hDlg,	DWL_MSGRESULT, PSNRET_NOERROR);
					break;

				case PSN_KILLACTIVE:
	        		SetWindowLong(hDlg,	DWL_MSGRESULT, FALSE);
   				return 1;
					break;
				case PSN_RESET:
					break;
        	}
         break;
      case WM_DESTROY:
      {
         break;
      }
      default: break;
   }

   return FALSE;
}
Пример #4
0
uint32_t write_ini(const uint8_t *file, uint8_t *header, uint8_t *key, uint8_t *data){
	uint8_t *path = safe_malloc(0x400);
	uint32_t ret;
	if(strstr(file, ":\\") == NULL){
		GetCurrentDirectory(0x400, path);
		sprintf_s(path, 0x400, "%s\\%s", path, file);
		ret = WritePrivateProfileStringA(header, key, data, path);
	}else{
		ret = WritePrivateProfileStringA(header, key, data, file);
	}
	free(path);
	return ret;
}
Пример #5
0
	int Save_Config(const char* filename)
	{
		char Str_Tmp [1024] = {0};
		if(!filename)
			filename = defaultConfigFilename;
		char Conf_File[1024];

		if(*filename && filename[1] == ':')
			strcpy(Conf_File, filename);
		else
			sprintf(Conf_File, "%s\\%s", thisprocessPath, filename);

		WritePrivateProfileStringA("General", "Exe path", exefilename, Conf_File);
		WritePrivateProfileStringA("General", "Movie path", moviefilename, Conf_File);
		WritePrivateProfileStringA("General", "Command line", commandline, Conf_File);

		SetPrivateProfileIntA("General", "Movie Read Only", nextLoadRecords, Conf_File);
		//SetPrivateProfileIntA("Graphics", "Force Windowed", localTASflags.forceWindowed, Conf_File);
		SetPrivateProfileIntA("Tools", "Fast Forward Flags", localTASflags.fastForwardFlags, Conf_File);
		if(advancePastNonVideoFramesConfigured)
			SetPrivateProfileIntA("Input", "Skip Lag Frames", advancePastNonVideoFrames, Conf_File);
		SetPrivateProfileIntA("Input", "Background Input Focus Flags", inputFocusFlags, Conf_File);
		SetPrivateProfileIntA("Input", "Background Hotkeys Focus Flags", hotkeysFocusFlags, Conf_File);

		SetPrivateProfileIntA("Debug", "Load Debug Tracing", traceEnabled, Conf_File);

		wsprintf(Str_Tmp, "%d", AutoRWLoad);
		WritePrivateProfileString("Watches", "AutoLoadWatches", Str_Tmp, Conf_File);

		wsprintf(Str_Tmp, "%d", RWSaveWindowPos);
		WritePrivateProfileString("Watches", "SaveWindowPosition", Str_Tmp, Conf_File);

		if (RWSaveWindowPos)
		{
			SetPrivateProfileIntA("Watches", "Ramwatch_X", ramw_x, Conf_File);
			SetPrivateProfileIntA("Watches", "Ramwatch_Y", ramw_y, Conf_File);
		}

		for(int i = 0; i < MAX_RECENT_WATCHES; i++)
		{
			char str[256];
			sprintf(str, "Recent Watch %d", i+1);
			WritePrivateProfileStringA("Watches", str, &rw_recent_files[i][0], Conf_File);	
		}

		// TODO: save hotkeys!
		//SaveHotkeys(Conf_File, true);
		//SaveHotkeys(Conf_File, false);

		return 1;
	}
Пример #6
0
int delete_ini_section(char *section)
{
	if(ini_file[0]!=0)
		return WritePrivateProfileStringA(section,NULL,NULL,ini_file);
	else
		return write_private_profile_string(section,NULL,NULL,&ram_ini);
}
Пример #7
0
	void SetStr(const char* value)
	{
		if( m_ParentPath.size() )
		{
			WritePrivateProfileStringA(m_ParentPath.c_str(), m_obj->m_name.c_str(), value, m_pPath->c_str());
		}
	}
Пример #8
0
void CIniReader::WriteBoolean(char* szSection, char* szKey, bool bolValue)
{
 char szValue[255];
 bool bolResult;
 sprintf(szValue, "%s", bolValue ? "True" : "False");
 WritePrivateProfileStringA(szSection, szKey, szValue, m_szFileName); 
}
Пример #9
0
void WriteConfig(const char *pszKey, const char *pszItem, const std::string& value)
{
  // avoid writing unless the value is actually different, because writing causes
  // an annoying popup when having the file open in e.g. notepad++
  if (LoadConfigStringFromFile(pszKey, pszItem, "_NULL") != value)
    WritePrivateProfileStringA(pszKey, pszItem, value.c_str(), configPath().c_str());
}
Пример #10
0
	void remove()
	{
		if( m_ParentPath.size() )
		{
			WritePrivateProfileStringA(m_ParentPath.c_str(), m_obj->m_name.c_str(), nullptr, m_pPath->c_str());
		}
	}
Пример #11
0
BOOL PERDXWriteGUID(u32 guidnum, u8 padnum, LPCSTR inifilename)
{
   char string1[20];
   char string2[40];
   sprintf(string1, "Peripheral%d%C", ((padnum/6)+1), 'A'+(padnum%6));
   sprintf(string2, "%08X-%04X-%04X-%02X%02X%02X%02X%02X%02X%02X%02X", (int)GUIDDevice[guidnum].Data1, (int)GUIDDevice[guidnum].Data2, (int)GUIDDevice[guidnum].Data3, (int)GUIDDevice[guidnum].Data4[0], (int)GUIDDevice[guidnum].Data4[1], (int)GUIDDevice[guidnum].Data4[2], (int)GUIDDevice[guidnum].Data4[3], (int)GUIDDevice[guidnum].Data4[4], (int)GUIDDevice[guidnum].Data4[5], (int)GUIDDevice[guidnum].Data4[6], (int)GUIDDevice[guidnum].Data4[7]);
   return WritePrivateProfileStringA(string1, "GUID", string2, inifilename);
}
Пример #12
0
void CIni::WriteStringUTF8(LPCTSTR strEntry, LPCTSTR psz, LPCTSTR strSection/* = NULL*/)
{
	USES_CONVERSION;
	if(strSection != NULL) 
		m_strSection = strSection;
	CString str(psz);
	WritePrivateProfileStringA(T2CA(m_strSection), T2CA(strEntry), StrToUtf8(str), T2CA(m_strFileName));
}
Пример #13
0
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Registry
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int WritePrivateProfileInt(LPCTSTR lpAppName, LPCTSTR lpKeyName, int iValue, LPCTSTR lpFileName)
{
	//////////////////////////////////////////////////////////////////////////
	///Helper function included to quickly & easily save integers to an Ini
	char szNumber[100];
	strcpy_s(szNumber, 100, "");
	_itoa_s(iValue, szNumber, 100, 10);
	return WritePrivateProfileStringA((LPCSTR)lpAppName, (LPCSTR)lpKeyName, szNumber, (LPCSTR)lpFileName);
}
Пример #14
0
int write_ini_str(char *section,char *key,char *str)
{
	if(ini_file[0]!=0){
		if(WritePrivateProfileStringA(section,key,str,ini_file)!=0)
			return TRUE;
		else
			return FALSE;
	}
	else{
		if(write_private_profile_string(section,key,str,&ram_ini)!=0)
			return TRUE;
		else
			return FALSE;
	}
}
Пример #15
0
static void test_profile_int(void)
{
    struct _profileInt profileInt[]={
         { NULL,    NULL, NULL,          NULL,     70, 0          , 0}, /*  0 */
         { NULL,    NULL, NULL,          TESTFILE, -1, 4294967295U, 0},
         { NULL,    NULL, NULL,          TESTFILE,  1, 1          , 0},
         { SECTION, NULL, NULL,          TESTFILE, -1, 4294967295U, 0},
         { SECTION, NULL, NULL,          TESTFILE,  1, 1          , 0},
         { NULL,    KEY,  NULL,          TESTFILE, -1, 4294967295U, 0}, /*  5 */
         { NULL,    KEY,  NULL,          TESTFILE,  1, 1          , 0},
         { SECTION, KEY,  NULL,          TESTFILE, -1, 4294967295U, 4294967295U},
         { SECTION, KEY,  NULL,          TESTFILE,  1, 1          , 1},
         { SECTION, KEY,  "-1",          TESTFILE, -1, 4294967295U, 4294967295U},
         { SECTION, KEY,  "-1",          TESTFILE,  1, 4294967295U, 4294967295U}, /* 10 */
         { SECTION, KEY,  "1",           TESTFILE, -1, 1          , 1},
         { SECTION, KEY,  "1",           TESTFILE,  1, 1          , 1},
         { SECTION, KEY,  "+1",          TESTFILE, -1, 1          , 0},
         { SECTION, KEY,  "+1",          TESTFILE,  1, 1          , 0},
         { SECTION, KEY,  "4294967296",  TESTFILE, -1, 0          , 0}, /* 15 */
         { SECTION, KEY,  "4294967296",  TESTFILE,  1, 0          , 0},
         { SECTION, KEY,  "4294967297",  TESTFILE, -1, 1          , 1},
         { SECTION, KEY,  "4294967297",  TESTFILE,  1, 1          , 1},
         { SECTION, KEY,  "-4294967297", TESTFILE, -1, 4294967295U, 4294967295U},
         { SECTION, KEY,  "-4294967297", TESTFILE,  1, 4294967295U, 4294967295U}, /* 20 */
         { SECTION, KEY,  "42A94967297", TESTFILE, -1, 42         , 42},
         { SECTION, KEY,  "42A94967297", TESTFILE,  1, 42         , 42},
         { SECTION, KEY,  "B4294967297", TESTFILE, -1, 0          , 0},
         { SECTION, KEY,  "B4294967297", TESTFILE,  1, 0          , 0},
    };
    int i, num_test = (sizeof(profileInt)/sizeof(struct _profileInt));
    UINT res;

    DeleteFileA( TESTFILE);

    for (i=0; i < num_test; i++) {
        if (profileInt[i].value)
            WritePrivateProfileStringA(SECTION, KEY, profileInt[i].value, 
                                      profileInt[i].iniFile);

       res = GetPrivateProfileIntA(profileInt[i].section, profileInt[i].key, 
                 profileInt[i].defaultVal, profileInt[i].iniFile); 
       ok((res == profileInt[i].result) || (res == profileInt[i].result9x),
	    "test<%02d>: ret<%010u> exp<%010u><%010u>\n",
            i, res, profileInt[i].result, profileInt[i].result9x);
    }

    DeleteFileA( TESTFILE);
}
Пример #16
0
int write_ini_value(char *section,char *key,int val)
{
	char str[20]={0};
	_snprintf(str,sizeof(str),"%i",val);
	if(ini_file[0]!=0){
		if(WritePrivateProfileStringA(section,key,str,ini_file)!=0)
			return TRUE;
		else
			return FALSE;
	}
	else{
		if(write_private_profile_string(section,key,str,&ram_ini)!=0)
			return TRUE;
		else
			return FALSE;
	}
}
Пример #17
0
bool SaveConfig( const char file[], const Config *cfg )
{
	char buff[8];
	bool succ;

	succ = WritePrivateProfileStringA( kMainSec, kAdapterKey, cfg->adapter, file );
	succ = WritePrivateProfileStringA( kMainSec, kPortKey, itoa( cfg->dst_port, buff, 10 ), file ) && succ;
	succ = WritePrivateProfileStringA( kMainSec, kFilterKey, itoa( cfg->filter, buff, 10 ), file ) && succ;
	succ = WritePrivateProfileStringA( kMainSec, kFilterWordsKey, cfg->filterwords, file ) && succ;
	succ = WritePrivateProfileStringA( kMainSec, kFilterIdURLKey, itoa( cfg->filteridurl, buff, 10 ), file ) && succ;
	succ = WritePrivateProfileStringA( kMainSec, kCheckUpdateKey, itoa( cfg->checkupdate, buff, 10 ), file ) && succ;

	return succ;
}//end SaveConfig
Пример #18
0
static int shell_execute(LPCSTR operation, LPCSTR file, LPCSTR parameters, LPCSTR directory)
{
    int rc;

    strcpy(shell_call, "ShellExecute(");
    strcat_param(shell_call, operation);
    strcat(shell_call, ", ");
    strcat_param(shell_call, file);
    strcat(shell_call, ", ");
    strcat_param(shell_call, parameters);
    strcat(shell_call, ", ");
    strcat_param(shell_call, directory);
    strcat(shell_call, ")");
    if (winetest_debug > 1)
        trace("%s\n", shell_call);

    DeleteFile(child_file);
    SetLastError(0xcafebabe);

    /* FIXME: We cannot use ShellExecuteEx() here because if there is no
     * association it displays the 'Open With' dialog and I could not find
     * a flag to prevent this.
     */
    rc=(int)ShellExecute(NULL, operation, file, parameters, directory,
                         SW_SHOWNORMAL);

    if (rc>=32)
    {
        int wait_rc;
        wait_rc=WaitForSingleObject(hEvent, 5000);
        ok(wait_rc==WAIT_OBJECT_0, "WaitForSingleObject returned %d\n", wait_rc);
    }
    /* The child process may have changed the result file, so let profile
     * functions know about it
     */
    WritePrivateProfileStringA(NULL, NULL, NULL, child_file);
    if (rc>=32)
        dump_child();

    return rc;
}
Пример #19
0
static void test_profile_string(void)
{
    HANDLE h;
    int ret;
    DWORD count;
    char buf[100];
    char *p;
    /* test that lines without an '=' will not be enumerated */
    /* in the case below, name2 is a key while name3 is not. */
    char content[]="[s]\r\nname1=val1\r\nname2=\r\nname3\r\nname4=val4\r\n";
    DeleteFileA( TESTFILE2);
    h = CreateFileA( TESTFILE2, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
        FILE_ATTRIBUTE_NORMAL, NULL);
    ok( h != INVALID_HANDLE_VALUE, " cannot create %s\n", TESTFILE2);
    if( h == INVALID_HANDLE_VALUE) return;
    WriteFile( h, content, sizeof(content), &count, NULL);
    CloseHandle( h);

    /* enumerate the keys */
    ret=GetPrivateProfileStringA( "s", NULL, "", buf, sizeof(buf),
        TESTFILE2);
    for( p = buf + strlen(buf) + 1; *p;p += strlen(p)+1) 
        p[-1] = ',';
    /* and test */
    ok( ret == 18 && !strcmp( buf, "name1,name2,name4"), "wrong keys returned(%d): %s\n", ret,
            buf);

    /* add a new key to test that the file is quite usable */
    WritePrivateProfileStringA( "s", "name5", "val5", TESTFILE2); 
    ret=GetPrivateProfileStringA( "s", NULL, "", buf, sizeof(buf),
        TESTFILE2);
    for( p = buf + strlen(buf) + 1; *p;p += strlen(p)+1) 
        p[-1] = ',';
    ok( ret == 24 && !strcmp( buf, "name1,name2,name4,name5"), "wrong keys returned(%d): %s\n",
            ret, buf);

    DeleteFileA( TESTFILE2);
}
Пример #20
0
LRESULT CALLBACK LogSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam,
                                    LPARAM lParam)
{
   switch (uMsg)
   {
      case WM_INITDIALOG:
      {
         // Setup use log setting
         SendDlgItemMessage(hDlg, IDC_USELOGCB, BM_SETCHECK, uselog ? BST_CHECKED : BST_UNCHECKED, 0);
         SendMessage(hDlg, WM_COMMAND, IDC_USELOGCB, 0);

         // Setup log type setting
         SendDlgItemMessage(hDlg, IDC_LOGTYPECB, CB_RESETCONTENT, 0, 0);
         SendDlgItemMessage(hDlg, IDC_LOGTYPECB, CB_ADDSTRING, 0, (LPARAM)_16("Write to File"));
         SendDlgItemMessage(hDlg, IDC_LOGTYPECB, CB_ADDSTRING, 0, (LPARAM)_16("Write to Window"));
         SendDlgItemMessage(hDlg, IDC_LOGTYPECB, CB_SETCURSEL, logtype, 0);

         // Setup log filename setting
         SetDlgItemText(hDlg, IDC_LOGFILENAMEET, _16(logfilename));

         // mini18n log settings
         SendDlgItemMessage(hDlg, IDC_USEMINI18NLOG, BM_SETCHECK, usemini18nlog ? BST_CHECKED : BST_UNCHECKED, 0);

         return TRUE;
      }
      case WM_COMMAND:
      {
         switch (LOWORD(wParam))
         {
            case IDC_USELOGCB:
            {
               if (SendDlgItemMessage(hDlg, LOWORD(wParam), BM_GETCHECK, 0, 0) == BST_CHECKED)
               {
                  SendMessage(hDlg, WM_COMMAND, (CBN_SELCHANGE << 16) | IDC_LOGTYPECB, 0);
                  EnableWindow(GetDlgItem(hDlg, IDC_LOGTYPECB), TRUE);
               }
               else
               {
                  EnableWindow(GetDlgItem(hDlg, IDC_LOGTYPECB), FALSE);
                  EnableWindow(GetDlgItem(hDlg, IDC_LOGFILENAMEET), FALSE);
                  EnableWindow(GetDlgItem(hDlg, IDC_LOGBROWSEBT), FALSE);
               }

               return TRUE;
            }
            case IDC_LOGTYPECB:
            {
               switch(HIWORD(wParam))
               {
                  case CBN_SELCHANGE:
                  {
                     if (SendDlgItemMessage(hDlg, IDC_LOGTYPECB, CB_GETCURSEL, 0, 0) == 0)
                     {
                        EnableWindow(GetDlgItem(hDlg, IDC_LOGFILENAMEET), TRUE);
                        EnableWindow(GetDlgItem(hDlg, IDC_LOGBROWSEBT), TRUE);
                     }
                     else
                     {
                        EnableWindow(GetDlgItem(hDlg, IDC_LOGFILENAMEET), FALSE);
                        EnableWindow(GetDlgItem(hDlg, IDC_LOGBROWSEBT), FALSE);
                     }

                     return TRUE;
                  }
                  default: break;
               }

               return TRUE;
            }
            case IDC_LOGBROWSEBT:
            {
               WCHAR tempwstr[MAX_PATH];
               WCHAR filter[1024];
               OPENFILENAME ofn;

               // setup ofn structure
               ZeroMemory(&ofn, sizeof(ofn));
               ofn.lStructSize = sizeof(ofn);
               ofn.hwndOwner = hDlg;

               CreateFilter(filter, 1024,
                  "Text Files", "*.txt",
                  "All Files", "*.*", NULL);

               ofn.lpstrFilter = filter;
               ofn.nFilterIndex = 1;
               GetDlgItemText(hDlg, IDC_LOGFILENAMEET, tempwstr, MAX_PATH);
               ofn.lpstrFile = tempwstr;
               ofn.nMaxFile = sizeof(tempwstr)/sizeof(WCHAR);
               ofn.Flags = OFN_OVERWRITEPROMPT;
               ofn.lpstrDefExt = _16("TXT");

               if (GetSaveFileName(&ofn))
               {
                  SetDlgItemText(hDlg, IDC_LOGFILENAMEET, tempwstr);
                  WideCharToMultiByte(CP_ACP, 0, tempwstr, -1, logfilename, MAX_PATH, NULL, NULL);
               }

               return TRUE;
            }
            case IDC_USEMINI18NLOG:
            {
               BOOL enabled;

               enabled = SendDlgItemMessage(hDlg, LOWORD(wParam), BM_GETCHECK, 0, 0) == BST_CHECKED ? TRUE : FALSE;

               EnableWindow(GetDlgItem(hDlg, IDC_MINI18NLOGFILENAME), enabled);
               EnableWindow(GetDlgItem(hDlg, IDC_MINI18NLOGBROWSE), enabled);

               return TRUE;
            }
            case IDC_MINI18NLOGBROWSE:
            {
               WCHAR tempwstr[MAX_PATH];
               WCHAR filter[1024];
               OPENFILENAME ofn;

               // setup ofn structure
               ZeroMemory(&ofn, sizeof(ofn));
               ofn.lStructSize = sizeof(ofn);
               ofn.hwndOwner = hDlg;

               CreateFilter(filter, 1024,
                  "Yabause Translation Files", "*.YTS",
                  "All Files", "*.*", NULL);

               ofn.lpstrFilter = filter;
               ofn.nFilterIndex = 1;
               GetDlgItemText(hDlg, IDC_MINI18NLOGFILENAME, tempwstr, MAX_PATH);
               ofn.lpstrFile = tempwstr;
               ofn.nMaxFile = sizeof(tempwstr)/sizeof(WCHAR);
               ofn.Flags = OFN_OVERWRITEPROMPT;
               ofn.lpstrDefExt = _16("YTS");

               if (GetSaveFileName(&ofn))
               {
                  SetDlgItemText(hDlg, IDC_MINI18NLOGFILENAME, tempwstr);
                  WideCharToMultiByte(CP_ACP, 0, tempwstr, -1, logfilename, MAX_PATH, NULL, NULL);
               }

               return TRUE;
            }
            default: break;
         }

         break;
      }
      case WM_NOTIFY:
     		switch (((NMHDR *) lParam)->code) 
    		{
				case PSN_SETACTIVE:
					break;

				case PSN_APPLY:
            {
               char tempstr[MAX_PATH];

               // Write use log setting
               if (SendDlgItemMessage(hDlg, IDC_USELOGCB, BM_GETCHECK, 0, 0) == BST_CHECKED)
                  uselog = 1;
               else
                  uselog = 0;

               sprintf(tempstr, "%d", uselog);
               WritePrivateProfileStringA("Log", "Enable", tempstr, inifilename);

               // Write log type setting
               logtype = (int)SendDlgItemMessage(hDlg, IDC_LOGTYPECB, CB_GETCURSEL, 0, 0);
               sprintf(tempstr, "%d", logtype);
               WritePrivateProfileStringA("Log", "Type", tempstr, inifilename);

               // Write log filename
               WritePrivateProfileStringA("Log", "Filename", logfilename, inifilename);

               // Write use mini18n log setting
               if (SendDlgItemMessage(hDlg, IDC_USELOGCB, BM_GETCHECK, 0, 0) == BST_CHECKED)
                  usemini18nlog = 1;
               else
                  usemini18nlog = 0;

               sprintf(tempstr, "%d", usemini18nlog);
               WritePrivateProfileStringA("Mini18nLog", "Enable", tempstr, inifilename);

               // Write mini18n log filename
               WritePrivateProfileStringA("Mini18nLog", "Filename", mini18nlogfilename, inifilename);

          		SetWindowLong(hDlg,	DWL_MSGRESULT, PSNRET_NOERROR);
					break;
            }
				case PSN_KILLACTIVE:
	        		SetWindowLong(hDlg,	DWL_MSGRESULT, FALSE);
   				return 1;
					break;
				case PSN_RESET:
					break;
        	}
         break;
      case WM_DESTROY:
      {
         break;
      }
      default: break;
   }

   return FALSE;
}
Пример #21
0
int WritePrivateProfileIntA(char *szSection, char *szItem, int iData, char *szPath)
{
	char szData[33];
	itoa(iData, szData, 10);
	return WritePrivateProfileStringA(szSection, szItem, szData, szPath);
}
Пример #22
0
void iniConfig::setStr(LPCSTR section, LPCSTR key, string value) const
{
	WritePrivateProfileStringA(section, key, (" " + value).c_str(), fileName);
}
Пример #23
0
static int shell_execute_ex(DWORD mask, LPCSTR operation, LPCSTR file,
                            LPCSTR parameters, LPCSTR directory)
{
    SHELLEXECUTEINFO sei;
    BOOL success;
    int rc;

    strcpy(shell_call, "ShellExecuteEx(");
    strcat_param(shell_call, operation);
    strcat(shell_call, ", ");
    strcat_param(shell_call, file);
    strcat(shell_call, ", ");
    strcat_param(shell_call, parameters);
    strcat(shell_call, ", ");
    strcat_param(shell_call, directory);
    strcat(shell_call, ")");
    if (winetest_debug > 1)
        trace("%s\n", shell_call);

    sei.cbSize=sizeof(sei);
    sei.fMask=SEE_MASK_NOCLOSEPROCESS | mask;
    sei.hwnd=NULL;
    sei.lpVerb=operation;
    sei.lpFile=file;
    sei.lpParameters=parameters;
    sei.lpDirectory=directory;
    sei.nShow=SW_SHOWNORMAL;
    sei.hInstApp=NULL; /* Out */
    sei.lpIDList=NULL;
    sei.lpClass=NULL;
    sei.hkeyClass=NULL;
    sei.dwHotKey=0;
    U(sei).hIcon=NULL;
    sei.hProcess=NULL; /* Out */

    DeleteFile(child_file);
    SetLastError(0xcafebabe);
    success=ShellExecuteEx(&sei);
    rc=(int)sei.hInstApp;
    ok((success && rc >= 32) || (!success && rc < 32),
       "%s rc=%d and hInstApp=%d is not allowed\n", shell_call, success, rc);

    if (rc>=32)
    {
        int wait_rc;
        if (sei.hProcess!=NULL)
        {
            wait_rc=WaitForSingleObject(sei.hProcess, 5000);
            ok(wait_rc==WAIT_OBJECT_0, "WaitForSingleObject(hProcess) returned %d\n", wait_rc);
        }
        wait_rc=WaitForSingleObject(hEvent, 5000);
        ok(wait_rc==WAIT_OBJECT_0, "WaitForSingleObject returned %d\n", wait_rc);
    }
    /* The child process may have changed the result file, so let profile
     * functions know about it
     */
    WritePrivateProfileStringA(NULL, NULL, NULL, child_file);
    if (rc>=32)
        dump_child();

    return rc;
}
Пример #24
0
static VOID MAIN_MenuCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
#if 0
  HLOCAL hActiveGroup    = GROUP_ActiveGroup();
  HLOCAL hActiveProgram  = PROGRAM_ActiveProgram(hActiveGroup);
  HWND   hActiveGroupWnd = GROUP_GroupWnd(hActiveGroup);

  switch(wParam)
    {
      /* Menu File */
    case PM_NEW:
      switch (DIALOG_New((hActiveGroupWnd && !IsIconic(hActiveGroupWnd)) ?
			 PM_NEW_PROGRAM : PM_NEW_GROUP))
      {
      case PM_NEW_PROGRAM:
	if (hActiveGroup) PROGRAM_NewProgram(hActiveGroup);
	break;

      case PM_NEW_GROUP:
	GROUP_NewGroup();
	break;
      }
      break;


    case PM_DELETE:
      if (hActiveProgram)
	{
	if (DIALOG_Delete(IDS_DELETE_PROGRAM_s, PROGRAM_ProgramName(hActiveProgram)))
	  PROGRAM_DeleteProgram(hActiveProgram, TRUE);
	}
      else if (hActiveGroup)
	{
	if (DIALOG_Delete(IDS_DELETE_GROUP_s, GROUP_GroupName(hActiveGroup)))
	  GROUP_DeleteGroup(hActiveGroup);
	}
      break;



    case PM_SAVE_SETTINGS:
      Globals.bSaveSettings = !Globals.bSaveSettings;
      CheckMenuItem(Globals.hOptionMenu, PM_SAVE_SETTINGS,
		    MF_BYCOMMAND | (Globals.bSaveSettings ?
				    MF_CHECKED : MF_UNCHECKED));
      WritePrivateProfileStringA("Settings", "SaveSettings",
				Globals.bSaveSettings ? "1" : "0",
				Globals.lpszIniFile);
      WritePrivateProfileStringA(NULL,NULL,NULL,Globals.lpszIniFile); /* flush it */
      break;


    case PM_ARRANGE:

      if (hActiveGroupWnd && !IsIconic(hActiveGroupWnd))
	ArrangeIconicWindows(hActiveGroupWnd);
      else
	SendMessageW(Globals.hMDIWnd, WM_MDIICONARRANGE, 0, 0);
      break;

    }




#endif

    DWORD Value;

    PROGGROUP* hActiveGroup;
    PROGRAM* hActiveProgram;
    HWND hActiveGroupWnd;

    hActiveGroup = GROUP_ActiveGroup();
    hActiveProgram = PROGRAM_ActiveProgram(hActiveGroup);
    hActiveGroupWnd = (hActiveGroup ? hActiveGroup->hWnd : NULL);

    switch (wParam)
    {
        /* Menu File */

        case PM_NEW:
        {
            BOOL Success;
            INT nResult;

            if (!hActiveGroupWnd || IsIconic(hActiveGroupWnd))
                Success = DIALOG_New(PM_NEW_GROUP, &nResult);
            else
                Success = DIALOG_New(PM_NEW_PROGRAM, &nResult);
            if (!Success)
                break;

            if (nResult & 1)
            {
                GROUPFORMAT format;
                BOOL bIsCommonGroup;

                format = (nResult & 0xC) >> 2;
                bIsCommonGroup = (nResult & 2) != 0;
                GROUP_NewGroup(format, bIsCommonGroup);
            }
            else if (hActiveGroup)
            {
                PROGRAM_NewProgram(hActiveGroup);
            }

            break;
        }
Пример #25
0
LRESULT CALLBACK InputSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam,
                                      LPARAM lParam)
{
   static helpballoon_struct hb[26];

   switch (uMsg)
   {
      case WM_INITDIALOG:
      {
         int i;
         u32 j;

         for (i = 0; i < 2; i++)
         {
            SendDlgItemMessage(hDlg, IDC_PORT1CONNTYPECB+i, CB_RESETCONTENT, 0, 0);
            SendDlgItemMessage(hDlg, IDC_PORT1CONNTYPECB+i, CB_ADDSTRING, 0, (LPARAM)_16("None"));
            SendDlgItemMessage(hDlg, IDC_PORT1CONNTYPECB+i, CB_ADDSTRING, 0, (LPARAM)_16("Direct"));
            SendDlgItemMessage(hDlg, IDC_PORT1CONNTYPECB+i, CB_ADDSTRING, 0, (LPARAM)_16("6-port Multitap"));
         }

         for (i = 0; i < 6; i++)
         {
            SendDlgItemMessage(hDlg, IDC_PORT1ATYPECB+i, CB_RESETCONTENT, 0, 0);
            SendDlgItemMessage(hDlg, IDC_PORT1ATYPECB+i, CB_ADDSTRING, 0, (LPARAM)_16("None"));
            SendDlgItemMessage(hDlg, IDC_PORT1ATYPECB+i, CB_ADDSTRING, 0, (LPARAM)_16("Standard Pad"));
/*
            SendDlgItemMessage(hDlg, IDC_PORT1ATYPECB+i, CB_ADDSTRING, 0, (LPARAM)_16("Analog Pad"));
            SendDlgItemMessage(hDlg, IDC_PORT1ATYPECB+i, CB_ADDSTRING, 0, (LPARAM)_16("Stunner"));
*/
            SendDlgItemMessage(hDlg, IDC_PORT1ATYPECB+i, CB_ADDSTRING, 0, (LPARAM)_16("Mouse"));
/*
            SendDlgItemMessage(hDlg, IDC_PORT1ATYPECB+i, CB_ADDSTRING, 0, (LPARAM)_16("Keyboard"));
*/
            SendDlgItemMessage(hDlg, IDC_PORT2ATYPECB+i, CB_RESETCONTENT, 0, 0);
            SendDlgItemMessage(hDlg, IDC_PORT2ATYPECB+i, CB_ADDSTRING, 0, (LPARAM)_16("None"));
            SendDlgItemMessage(hDlg, IDC_PORT2ATYPECB+i, CB_ADDSTRING, 0, (LPARAM)_16("Standard Pad"));
/*
            SendDlgItemMessage(hDlg, IDC_PORT2ATYPECB+i, CB_ADDSTRING, 0, (LPARAM)_16("Analog Pad"));
            SendDlgItemMessage(hDlg, IDC_PORT2ATYPECB+i, CB_ADDSTRING, 0, (LPARAM)_16("Stunner"));
*/
            SendDlgItemMessage(hDlg, IDC_PORT2ATYPECB+i, CB_ADDSTRING, 0, (LPARAM)_16("Mouse"));
/*
            SendDlgItemMessage(hDlg, IDC_PORT2ATYPECB+i, CB_ADDSTRING, 0, (LPARAM)_16("Keyboard"));
*/
            SendDlgItemMessage(hDlg, IDC_PORT1ATYPECB+i, CB_SETCURSEL, 0, 0);
            EnableWindow(GetDlgItem(hDlg, IDC_PORT1ATYPECB+i), FALSE);
            EnableWindow(GetDlgItem(hDlg, IDC_PORT1ACFGPB+i), FALSE);

            SendDlgItemMessage(hDlg, IDC_PORT2ATYPECB+i, CB_SETCURSEL, 0, 0);
            EnableWindow(GetDlgItem(hDlg, IDC_PORT2ATYPECB+i), FALSE);
            EnableWindow(GetDlgItem(hDlg, IDC_PORT2ACFGPB+i), FALSE);
         }

         SendDlgItemMessage(hDlg, IDC_PORT1CONNTYPECB, CB_SETCURSEL, porttype[0], 0);
         PostMessage(hDlg, WM_COMMAND, MAKEWPARAM(IDC_PORT1CONNTYPECB, CBN_SELCHANGE), (LPARAM)GetDlgItem(hDlg, IDC_PORT1CONNTYPECB));

         SendDlgItemMessage(hDlg, IDC_PORT2CONNTYPECB, CB_SETCURSEL, porttype[1], 0);
         PostMessage(hDlg, WM_COMMAND, MAKEWPARAM(IDC_PORT2CONNTYPECB, CBN_SELCHANGE), (LPARAM)GetDlgItem(hDlg, IDC_PORT2CONNTYPECB));

         EnableWindow(GetDlgItem(hDlg, IDC_PORT1ATYPECB), TRUE);
         EnableWindow(GetDlgItem(hDlg, IDC_PORT2ATYPECB), TRUE);

         if (!PERCore)
         {
            SendDlgItemMessage(hDlg, IDC_PORT1ATYPECB, CB_SETCURSEL, 1, 0);
            EnableWindow(GetDlgItem(hDlg, IDC_PORT1ACFGPB), TRUE);            
         }

         // Go through previous settings and figure out which controls to 
         // enable, etc.
         for (j = 0; j < numpads; j++)
         {
            if (paddevice[j].emulatetype != 0)
            {
               int id=0;
               switch (pad[j]->perid)
               {
                  case PERPAD:
                     id = 1;
                     break;
                  case PERMOUSE:
                     id = 2;
                     break;
                  default: break;
               }

               SendDlgItemMessage(hDlg, IDC_PORT1ATYPECB+j, CB_SETCURSEL, id, 0);
               EnableWindow(GetDlgItem(hDlg, IDC_PORT1ACFGPB+j), TRUE);            
            }
         }

         // Setup Tooltips
         hb[0].string = "Use this to select whether to use a multi-tap or direct connection";
         hb[0].hParent = GetDlgItem(hDlg, IDC_PORT1CONNTYPECB);
         hb[1].string = hb[0].string;
         hb[1].hParent = GetDlgItem(hDlg, IDC_PORT2CONNTYPECB);

         for (i = 0; i < 6; i++)
         {
            hb[2+i].string = "Use this to select what kind of peripheral to emulate";
            hb[2+i].hParent = GetDlgItem(hDlg, IDC_PORT1ATYPECB+i);
            hb[8+i].string = hb[2+i].string;
            hb[8+i].hParent = GetDlgItem(hDlg, IDC_PORT2ATYPECB+i);            

            hb[14+i].string = "Press this to change the button configuration, etc.";
            hb[14+i].hParent = GetDlgItem(hDlg, IDC_PORT1ACFGPB+i);
            hb[20+i].string = hb[14+i].string;
            hb[20+i].hParent = GetDlgItem(hDlg, IDC_PORT2ACFGPB+i);            
         }
         
         hb[26].string = NULL;

         CreateHelpBalloons(hb);

         return TRUE;
      }
      case WM_COMMAND:
      {
         switch (LOWORD(wParam))
         {
            case IDC_PORT1CONNTYPECB:
            case IDC_PORT2CONNTYPECB:
            {
               int i, id, id2;

               switch(HIWORD(wParam))
               {
                  case CBN_SELCHANGE:
                     switch(ComboBox_GetCurSel((HWND)lParam))
                     {
                        case 0: // None
                           if (LOWORD(wParam) == IDC_PORT1CONNTYPECB)
                           {
                              id = IDC_PORT1ATYPECB;
                              id2 = IDC_PORT1ACFGPB;
                           }
                           else
                           {
                              id = IDC_PORT2ATYPECB;
                              id2 = IDC_PORT2ACFGPB;
                           }

                           for (i = 0; i < 6; i++)
                           {
                              EnableWindow(GetDlgItem(hDlg, id+i), FALSE);
                              EnableWindow(GetDlgItem(hDlg, id2+i), FALSE);
                           }
                           break;
                        case 1: // Direct
                           if (LOWORD(wParam) == IDC_PORT1CONNTYPECB)
                           {
                              id = IDC_PORT1ATYPECB;
                              id2 = IDC_PORT1ACFGPB;
                           }
                           else
                           {
                              id = IDC_PORT2ATYPECB;
                              id2 = IDC_PORT2ACFGPB;
                           }

                           EnableWindow(GetDlgItem(hDlg, id), TRUE);
                           PostMessage(hDlg, WM_COMMAND, MAKEWPARAM(id, CBN_SELCHANGE), (LPARAM)GetDlgItem(hDlg, id));

                           for (i = 1; i < 6; i++)
                           {
                              EnableWindow(GetDlgItem(hDlg, id+i), FALSE);
                              EnableWindow(GetDlgItem(hDlg, id2+i), FALSE);
                           }
                           break;
                        case 2: // Multi-tap
                           id = (LOWORD(wParam) == IDC_PORT1CONNTYPECB ? IDC_PORT1ATYPECB : IDC_PORT2ATYPECB);

                           for (i = 0; i < 6; i++)
                           {
                              EnableWindow(GetDlgItem(hDlg, id+i), TRUE);
                              PostMessage(hDlg, WM_COMMAND, MAKEWPARAM(id+i, CBN_SELCHANGE), (LPARAM)GetDlgItem(hDlg, id+i));
                           }
                           break;
                        default: break;
                     }

                     break;
                  default: break;
               }
               break;
            }
            case IDC_PORT1ATYPECB:
            case IDC_PORT1BTYPECB:
            case IDC_PORT1CTYPECB:
            case IDC_PORT1DTYPECB:
            case IDC_PORT1ETYPECB:
            case IDC_PORT1FTYPECB:
            case IDC_PORT2ATYPECB:
            case IDC_PORT2BTYPECB:
            case IDC_PORT2CTYPECB:
            case IDC_PORT2DTYPECB:
            case IDC_PORT2ETYPECB:
            case IDC_PORT2FTYPECB:
            {
               switch(HIWORD(wParam))
               {
                  case CBN_SELCHANGE:
                     // If emulated peripheral is set to none, we don't want 
                     // the config button enabled
                     if (ComboBox_GetCurSel((HWND)lParam) != 0)
                        Button_Enable(GetDlgItem(hDlg, IDC_PORT1ACFGPB+(int)LOWORD(wParam)-IDC_PORT1ATYPECB), TRUE);
                     else
                        Button_Enable(GetDlgItem(hDlg, IDC_PORT1ACFGPB+(int)LOWORD(wParam)-IDC_PORT1ATYPECB), FALSE);

                     break;
                  default: break;
               }
               break;
            }
            case IDC_PORT1ACFGPB:
            case IDC_PORT1BCFGPB:
            case IDC_PORT1CCFGPB:
            case IDC_PORT1DCFGPB:
            case IDC_PORT1ECFGPB:
            case IDC_PORT1FCFGPB:
            case IDC_PORT2ACFGPB:
            case IDC_PORT2BCFGPB:
            case IDC_PORT2CCFGPB:
            case IDC_PORT2DCFGPB:
            case IDC_PORT2ECFGPB:
            case IDC_PORT2FCFGPB:
               switch (ComboBox_GetCurSel(GetDlgItem(hDlg, IDC_PORT1ATYPECB+LOWORD(wParam)-IDC_PORT1ACFGPB)))
               {
                  case 1:
                     // Standard Pad
                     DialogBoxParam(y_hInstance, MAKEINTRESOURCE(IDD_PADCONFIG), hDlg, (DLGPROC)PadConfigDlgProc, (LPARAM)LOWORD(wParam)-IDC_PORT1ACFGPB);
                     break;
                  case 2:
                     // Mouse
                     DialogBoxParam(y_hInstance, MAKEINTRESOURCE(IDD_MOUSECONFIG), hDlg, (DLGPROC)MouseConfigDlgProc, (LPARAM)LOWORD(wParam)-IDC_PORT1ACFGPB);
                     break;
                  default: break;
               }
               return TRUE;
            default: break;
         }

         break;
      }
      case WM_NOTIFY:
     		switch (((NMHDR *) lParam)->code) 
    		{
				case PSN_SETACTIVE:
					break;

				case PSN_APPLY:
            {
               u32 i, j;
               char string1[13], string2[32];

               for (i = 0; i < 2; i++)
               {
                  int cursel=(int)SendDlgItemMessage(hDlg, IDC_PORT1CONNTYPECB+i, CB_GETCURSEL, 0, 0);

                  sprintf(string1, "Port%dType", (int)i+1);
                  sprintf(string2, "%d", cursel);
                  WritePrivateProfileStringA("Input", string1, string2, inifilename);

                  for (j = 0; j < 6; j++)
                  {
                     sprintf(string1, "Peripheral%ld%C", i+1, 'A'+j);
                     sprintf(string2, "%d", ConvertEmulateTypeSelStringToID(hDlg, IDC_PORT1ATYPECB+(i*6)+j));
                     WritePrivateProfileStringA(string1, "EmulateType", string2, inifilename);
                  }
               }

               SetWindowLong(hDlg,	DWL_MSGRESULT, PSNRET_NOERROR);
					break;
            }
				case PSN_KILLACTIVE:
	        		SetWindowLong(hDlg,	DWL_MSGRESULT, FALSE);
   				return 1;
					break;
				case PSN_RESET:
					break;
        	}
         break;
      case WM_DESTROY:
      {
         // Reload device(s)
         PERDXLoadDevices(inifilename);

         DestroyHelpBalloons(hb);
         break;
      }
      default: break;
   }

   return FALSE;
}
Пример #26
0
LRESULT CALLBACK MouseConfigDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam,
                                    LPARAM lParam)
{
   static u8 cursel;
   static BOOL enablebuttons;
   static int controlmap[13];
   static int padnum;
   static HWND hParent;
   static int emulatetype;
   int i;

   switch (uMsg)
   {
      case WM_INITDIALOG:
      {
         padnum = (int)lParam;

         hParent = PropSheet_GetCurrentPageHwnd(GetParent(hDlg));
         emulatetype = ConvertEmulateTypeSelStringToID(hParent, IDC_PORT1ATYPECB+padnum);
         PERDXListDevices(GetDlgItem(hDlg, IDC_DXDEVICECB), emulatetype);

         // Load settings from ini here, if necessary
         PERDXInitControlConfig(hDlg, padnum, controlmap, inifilename);

         cursel = (u8)SendDlgItemMessage(hDlg, IDC_DXDEVICECB, CB_GETCURSEL, 0, 0);
         enablebuttons = cursel ? TRUE : FALSE;

         EnableWindow(GetDlgItem(hDlg, IDC_STARTPB), enablebuttons);
         EnableWindow(GetDlgItem(hDlg, IDC_APB), enablebuttons);
         EnableWindow(GetDlgItem(hDlg, IDC_BPB), enablebuttons);
         EnableWindow(GetDlgItem(hDlg, IDC_CPB), enablebuttons);
         return TRUE;
      }
      case WM_COMMAND:
      {
         switch (LOWORD(wParam))
         {
            case IDC_STARTPB:
            case IDC_APB:
            case IDC_BPB:
            case IDC_CPB:
            {
               DoControlConfig(hDlg, cursel-1, IDC_UPTEXT+(LOWORD(wParam)-IDC_UPPB), IDC_UPTEXT, controlmap);

               return TRUE;
            }
            case IDOK:
            {
               char string1[20];
               char string2[20];

               EndDialog(hDlg, TRUE);

               sprintf(string1, "Peripheral%d%C", ((padnum/6)+1), 'A'+(padnum%6));

               // Write GUID
               PERDXWriteGUID(cursel-1, padnum, inifilename);

               for (i = 0; i < 13; i++)
               {
                  sprintf(string2, "%d", controlmap[i]);
                  WritePrivateProfileStringA(string1, PerPadNames[i], string2, inifilename);
               }
               return TRUE;
            }
            case IDCANCEL:
            {
               EndDialog(hDlg, FALSE);
               return TRUE;
            }
            case IDC_DXDEVICECB:
            {
               switch(HIWORD(wParam))
               {
                  case CBN_SELCHANGE:
                  {
                     cursel = (u8)SendDlgItemMessage(hDlg, IDC_DXDEVICECB, CB_GETCURSEL, 0, 0);
                     enablebuttons = cursel ? TRUE : FALSE;

                     EnableWindow(GetDlgItem(hDlg, IDC_STARTPB), enablebuttons);
                     EnableWindow(GetDlgItem(hDlg, IDC_APB), enablebuttons);
                     EnableWindow(GetDlgItem(hDlg, IDC_BPB), enablebuttons);
                     EnableWindow(GetDlgItem(hDlg, IDC_CPB), enablebuttons);
                     break;
                  }
                  default: break;
               }
               break;
            }
            default: break;
         }

         break;
      }
      case WM_DESTROY:
      {
         break;
      }
   }

   return FALSE;
}
Пример #27
0
/***********************************************************************
 *           WritePrivateProfileString   (KERNEL.129)
 */
BOOL16 WINAPI WritePrivateProfileString16( LPCSTR section, LPCSTR entry,
                                           LPCSTR string, LPCSTR filename )
{
    return WritePrivateProfileStringA(section,entry,string,filename);
}
Пример #28
0
void iniConfig::removeKey(LPCSTR section, LPCSTR key) const { WritePrivateProfileStringA(section, key, nullptr, fileName); }
Пример #29
0
void PERDXLoadDevices(char *inifilename)
{
   char tempstr[MAX_PATH];
   char string1[20];
   char string2[20];
   GUID guid;
   DIDEVCAPS didc;
   u32 i;
   int j, i2;
   int buttonid;
   DIPROPDWORD dipdw;
   int id;
   DWORD coopflags=DISCL_FOREGROUND | DISCL_NONEXCLUSIVE;
   BOOL loaddefault=TRUE;
   int numpads;
   HRESULT hr;

   if (!PERCore)
      return;
   PerPortReset();
   memset(pad, 0, sizeof(pad));

   // Check Connection Type
   if (GetPrivateProfileStringA("Input", "Port1Type", "", tempstr, MAX_PATH, inifilename) == 0)
   {
      // Check if it's using the old ini settings for peripherals
      if (GetPrivateProfileStringA("Peripheral1", "GUID", "", tempstr, MAX_PATH, inifilename) != 0)
      {
         // Convert to the newer type of settings
         for (i = 0; i < 2; i++)
         {
            sprintf(string1, "Port%dType", (int)i+1);
            WritePrivateProfileStringA("Input", string1, "1", inifilename);

            sprintf(string1, "Peripheral%d", (int)i+1);
            sprintf(string2, "Peripheral%dA", (int)i+1);

            if (GetPrivateProfileStringA(string1, "GUID", "", tempstr, MAX_PATH, inifilename))
               WritePrivateProfileStringA(string2, "GUID", tempstr, inifilename);

            if (GetPrivateProfileStringA(string1, "EmulateType", "", tempstr, MAX_PATH, inifilename))
               WritePrivateProfileStringA(string2, "EmulateType", tempstr, inifilename);

            for (i2 = 0; i2 < 13; i2++)
            {
               if (GetPrivateProfileStringA(string1, PerPadNames[i2], "", tempstr, MAX_PATH, inifilename))
                  WritePrivateProfileStringA(string2, PerPadNames[i2], tempstr, inifilename);
            }
         }

         // Remove old ini entries
         for (i = 0; i < 12; i++)
         {
            sprintf(string1, "Peripheral%d", (int)i+1);
            WritePrivateProfileStringA(string1, NULL, NULL, inifilename);
         }

         loaddefault = FALSE;
      }
   }
   else 
      loaddefault = FALSE;

   if (loaddefault)
   {
      LoadDefaultPort1A();
      return;
   }

   // Load new type settings
   for (i = 0; i < 2; i++)
   {
      sprintf(string1, "Port%dType", (int)i+1);

      if (GetPrivateProfileStringA("Input", string1, "", tempstr, MAX_PATH, inifilename) != 0)
      {
         porttype[i] = atoi(tempstr);

         switch(porttype[i])
         {
            case 1:
               numpads = 1;
               break;
            case 2:
               numpads = 6;
               break;
            default:
               numpads = 0;
               break;
         }

         // Load new type settings
         for (j = 0; j < numpads; j++)
         {
            int padindex=(6*i)+j;
            padconf_struct *curdevice=&paddevice[padindex];
            sprintf(string1, "Peripheral%d%C", (int)i+1, 'A' + j);

            // Let's first fetch the guid of the device
            if (GetPrivateProfileStringA(string1, "GUID", "", tempstr, MAX_PATH, inifilename) == 0)
               continue;

            if (GetPrivateProfileStringA(string1, "EmulateType", "0", string2, MAX_PATH, inifilename))
            {
               curdevice->emulatetype = atoi(string2);
               if (curdevice->emulatetype == 0)
                  continue;
            }

            if (curdevice->lpDIDevice)
            {
               // Free the default keyboard, etc.
               IDirectInputDevice8_Unacquire(curdevice->lpDIDevice);
               IDirectInputDevice8_Release(curdevice->lpDIDevice);
            }

            StringToGUID(tempstr, &guid);

            // Ok, now that we've got the GUID of the device, let's set it up
            if (FAILED(IDirectInput8_CreateDevice(lpDI8, &guid, &lpDIDevice[padindex],
               NULL) ))
            {
               curdevice->lpDIDevice = NULL;
               curdevice->emulatetype = 0;
               continue;
            }

            curdevice->lpDIDevice = lpDIDevice[padindex];

            didc.dwSize = sizeof(DIDEVCAPS);

            if (FAILED(IDirectInputDevice8_GetCapabilities(lpDIDevice[padindex], &didc) ))
               continue;

            if (GET_DIDEVICE_TYPE(didc.dwDevType) == DI8DEVTYPE_KEYBOARD)
            {
               if (FAILED(IDirectInputDevice8_SetDataFormat(lpDIDevice[padindex], &c_dfDIKeyboard) ))
                  continue;
               curdevice->type = TYPE_KEYBOARD;
               coopflags |= DISCL_NOWINKEY;
            }       
            else if (GET_DIDEVICE_TYPE(didc.dwDevType) == DI8DEVTYPE_GAMEPAD ||
               GET_DIDEVICE_TYPE(didc.dwDevType) == DI8DEVTYPE_JOYSTICK)
            {
               if (FAILED(IDirectInputDevice8_SetDataFormat(lpDIDevice[padindex], &c_dfDIJoystick2) ))
                  continue;
               curdevice->type = TYPE_JOYSTICK;
            }
            else if (GET_DIDEVICE_TYPE(didc.dwDevType) == DI8DEVTYPE_MOUSE)
            {
               if (FAILED(IDirectInputDevice8_SetDataFormat(lpDIDevice[padindex], &c_dfDIMouse2) ))
                  continue;
               curdevice->type = TYPE_MOUSE;
               coopflags = DISCL_FOREGROUND | DISCL_EXCLUSIVE;
            }

            hr = IDirectInputDevice8_SetCooperativeLevel(lpDIDevice[i], DXGetWindow(), coopflags);
            if (FAILED(hr))
               continue;

            dipdw.diph.dwSize = sizeof(DIPROPDWORD);
            dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER);
            dipdw.diph.dwObj = 0;
            dipdw.diph.dwHow = DIPH_DEVICE;
            dipdw.dwData = 8; // should be enough

            // Setup Buffered input
            if (FAILED(IDirectInputDevice8_SetProperty(lpDIDevice[padindex], DIPROP_BUFFERSIZE, &dipdw.diph)))
               continue;

            IDirectInputDevice8_Acquire(lpDIDevice[padindex]);

            switch(curdevice->emulatetype)
            {
               case 1: // Standard Pad
                  id = PERPAD;
                  break;
               case 2: // Analog Pad
               case 3: // Stunner
               case 5: // Keyboard
                  id = 0;
                  break;
               case 4: // Mouse
                  id = PERMOUSE;
                  break;
               default: break;
            }

            // Make sure we're added to the smpc list
            if (i == 0)
               pad[padindex] = PerAddPeripheral(&PORTDATA1, id);
            else
               pad[padindex] = PerAddPeripheral(&PORTDATA2, id);

            // Now that we're all setup, let's fetch the controls from the ini
            if (curdevice->emulatetype != 3 &&
               curdevice->emulatetype != 4)
            {
               for (i2 = 0; i2 < 13; i2++)
               {
                  buttonid = GetPrivateProfileIntA(string1, PerPadNames[i2], 0, inifilename);
                  PerSetKey(buttonid, i2, pad[padindex]);
               }
            }
            else if (curdevice->emulatetype == 4)
            {
               for (i2 = 0; i2 < 4; i2++)
               {
                  buttonid = GetPrivateProfileIntA(string1, mouse_names[i2], 0, inifilename);
                  PerSetKey(buttonid, PERMOUSE_LEFT+i2, pad[padindex]);
               }
            }
         }
      }
   }
}
Пример #30
0
CHveDbController::CHveDbController(CList<RESULT_ELEMENT>* pListResult, SINGLE_HVE_ELEMENT* pSingleHveElement, ISemaphore* pSemaphore, CCriticalSection* pcsResult)
{
	m_pListResult = pListResult;
	m_SingleHveElement = pSingleHveElement;
	m_pSemaphore = pSemaphore;
	m_pcsResult = pcsResult;
	m_fComIsInited = FALSE;
	m_strServerIP = "127.0.0.1";
	m_strDataBase = "HVE_DATA";
	m_strUserName = "******";
	m_strPassword = "******";
	char szAppPath[MAX_PATH] = {0};
	GetModuleFileName(NULL, szAppPath, MAX_PATH);
	PathRemoveFileSpec(szAppPath);
	strcat(szAppPath, "\\Config.ini");
	char szTmp[256] = {0};
	GetPrivateProfileStringA("DBInfo", "ServerIP", "", szTmp, 256, szAppPath);
	if(strcmp(szTmp, "") == 0)
	{
		WritePrivateProfileStringA("DBInfo", "ServerIP", m_strServerIP.GetBuffer(), szAppPath);
	}
	else
	{
		m_strServerIP = szTmp;
	}

	GetPrivateProfileStringA("DBInfo", "DataBase", "", szTmp, 256, szAppPath);
	if(strcmp(szTmp, "") == 0)
	{
		WritePrivateProfileStringA("DBInfo", "DataBase", m_strDataBase.GetBuffer(), szAppPath);
	}
	else
	{
		m_strDataBase = szTmp;
	}

	GetPrivateProfileStringA("DBInfo", "UserName", "", szTmp, 256, szAppPath);
	if(strcmp(szTmp, "") == 0)
	{
		WritePrivateProfileStringA("DBInfo", "UserName", m_strUserName.GetBuffer(), szAppPath);
	}
	else
	{
		m_strUserName = szTmp;
	}

	GetPrivateProfileStringA("DBInfo", "Password", "", szTmp, 256, szAppPath);
	if(strcmp(szTmp, "") == 0)
	{
		WritePrivateProfileStringA("DBInfo", "Password", m_strPassword.GetBuffer(), szAppPath);
	}
	else
	{
		m_strPassword = szTmp;
	}

	m_fIsConnecting = FALSE;
	m_strColumns.Format("Location_Id, Pass_Time, Plate_No, Road_No, Road_Name, Road_Direct, Car_Speed, Obj_Id, Time_Headway, Over_Line, Cross_Line, Emergency_Stop, Reverse_Run, Speeding, Special_Result, big_image_1_path, big_image_2_path, big_image_3_path, big_image_4_path, big_image_5_path, small_image_path, bin_image_path, video_path");
	m_fExit = FALSE;
	DWORD dwThreadId;
	m_hSaveThread = CreateThread(NULL, 0, SaveProcProxy, this, 0, &dwThreadId);

}