Example #1
0
BOOL CMcCurveData::ReadCurveData()
{
	WIN32_FIND_DATA fd;
	HANDLE handle=FindFirstFile(strfilepath,&fd);
	if (handle==INVALID_HANDLE_VALUE)
	{
		return FALSE;
	}
	FindClose(handle);
	//stroldsection.Format("mc_n%02dl%03du%03d",nNode,nLine,nRtu);
	stroldsection=strMcename;
	
	char szsection[20];
	ZeroMemory(szsection,20);
	GetPrivateProfileSection(stroldsection,szsection,20,strfilepath);
	if (strlen(szsection)==0)
	{
		return FALSE;
	}
	gtIcurvearray.RemoveAll();
	gtVcurvearray.RemoveAll();
	zbIcurvearray.RemoveAll();
	zbVcurvearray.RemoveAll();
	char szrec[80];
	char sz0[20];
	char sz1[20];
	char sz2[20];
	char sz3[20];
	char sz4[20];
	char sz5[20];
	char sz6[20];
	char sz7[20];
	char sz8[20];

	char nUpName[33];
	char nDownName[33];

	strcpy(nUpName,"");
	strcpy(nDownName,"");
	
	
	nIprecision=GetPrivateProfileInt(stroldsection,"Iprecision",0,strfilepath);
	nVprecision=GetPrivateProfileInt(stroldsection,"Vprecision",0,strfilepath);
	//fImin=GetPrivateProfileInt(stroldsection,"Imin",0,strfilepath);
	GetPrivateProfileString(stroldsection,"Imin",0,szrec,80,strfilepath);
	fImin=atof(szrec);
	//fImax=GetPrivateProfileInt(stroldsection,"Imax",30,strfilepath);
	GetPrivateProfileString(stroldsection,"Imax",0,szrec,80,strfilepath);
	fImax=atof(szrec);
	//fVmin=GetPrivateProfileInt(stroldsection,"Vmin",0,strfilepath);
	GetPrivateProfileString(stroldsection,"Vmin",0,szrec,80,strfilepath);
	fVmin=atof(szrec);
	//fVmax=GetPrivateProfileInt(stroldsection,"Vmax",300,strfilepath);
	GetPrivateProfileString(stroldsection,"Vmax",0,szrec,80,strfilepath);
	fVmax=atof(szrec);
	bgtmode=GetPrivateProfileInt(stroldsection,"gtmode",1,strfilepath);

	bonlyrealline=GetPrivateProfileInt(stroldsection,"onlyrealline",0,strfilepath);
	m_realtime_style=GetPrivateProfileInt(stroldsection,"realtime_style",0,strfilepath);
	nNode=GetPrivateProfileInt(stroldsection,"node",0,strfilepath);
	nLine=GetPrivateProfileInt(stroldsection,"line",0,strfilepath);
	nRtu=GetPrivateProfileInt(stroldsection,"rtu",0,strfilepath);
	
	GetPrivateProfileString(stroldsection,"UpName","",nUpName,sizeof(char)*32,strfilepath);
	GetPrivateProfileString(stroldsection,"DownName","",nDownName,sizeof(char)*32,strfilepath);
	UpName=nUpName;
	DownName=nDownName;

	TCurve addTcurve;
	CString singlecurvekey;
	
	int curvecount=GetPrivateProfileInt(stroldsection,"gtIlinecount",0,strfilepath);
	for (int i=0; i<curvecount; i++)
	{

		singlecurvekey.Format("gtIline%d",i);
		GetPrivateProfileString(stroldsection,singlecurvekey,0,szrec,79,strfilepath);
		
		extractstring(szrec,sz0,sz1,sz2,sz3,sz4,sz5,sz6,sz7,sz8);
		memset(&addTcurve,0,sizeof(TCurve));
		addTcurve.ncurvecolor=atoi(sz0);
		addTcurve.BcurvechannelNO=atoi(sz1);
		addTcurve.nlinenode=atoi(sz2);
		addTcurve.nlineline=atoi(sz3);
		addTcurve.nlinertu=atoi(sz4);
		addTcurve.Bdot=atoi(sz5);
		addTcurve.fcurveratio=atof(sz6);
		addTcurve.Bprecision=atoi(sz7);
		if (strlen(sz8)>0)
			strcpy(addTcurve.unit,sz8);
		gtIcurvearray.Add(addTcurve);
	}

	curvecount=GetPrivateProfileInt(stroldsection,"gtVlinecount",0,strfilepath);
	for (int i=0; i<curvecount; i++)
	{
		singlecurvekey.Format("gtVline%d",i);
		GetPrivateProfileString(stroldsection,singlecurvekey,0,szrec,79,strfilepath);
		extractstring(szrec,sz0,sz1,sz2,sz3,sz4,sz5,sz6,sz7,sz8);
	    memset(&addTcurve,0,sizeof(TCurve)); 
		addTcurve.ncurvecolor=atoi(sz0);
		addTcurve.BcurvechannelNO=atoi(sz1);
		addTcurve.nlinenode=atoi(sz2);
		addTcurve.nlineline=atoi(sz3);
		addTcurve.nlinertu=atoi(sz4);
		addTcurve.Bdot=atoi(sz5);
		addTcurve.fcurveratio=atof(sz6);
		addTcurve.Bprecision=atoi(sz7);
		if (strlen(sz8)>0)
			strcpy(addTcurve.unit,sz8);
		gtVcurvearray.Add(addTcurve);
	}

	if (bgtmode)
	{
		curvecount=GetPrivateProfileInt(stroldsection,"zbIlinecount",0,strfilepath);
		for (int i=0; i<curvecount; i++)
		{
			singlecurvekey.Format("zbIline%d",i);
			GetPrivateProfileString(stroldsection,singlecurvekey,0,szrec,80,strfilepath);
			extractstring(szrec,sz0,sz1,sz2,sz3,sz4,sz5,sz6,sz7,sz8);
			memset(&addTcurve,0,sizeof(TCurve));
			addTcurve.ncurvecolor=atoi(sz0);
			addTcurve.BcurvechannelNO=atoi(sz1);
			addTcurve.nlinenode=atoi(sz2);
			addTcurve.nlineline=atoi(sz3);
			addTcurve.nlinertu=atoi(sz4);
			addTcurve.Bdot=atoi(sz5);
			addTcurve.fcurveratio=atof(sz6);
			addTcurve.Bprecision=atoi(sz7);
			if (strlen(sz8)>0)
				strcpy(addTcurve.unit,sz8);
			zbIcurvearray.Add(addTcurve);
		}

		curvecount=GetPrivateProfileInt(stroldsection,"zbVlinecount",0,strfilepath);
		for (int i=0; i<curvecount; i++)
		{
			singlecurvekey.Format("zbVline%d",i);
			GetPrivateProfileString(stroldsection,singlecurvekey,0,szrec,80,strfilepath);
			extractstring(szrec,sz0,sz1,sz2,sz3,sz4,sz5,sz6,sz7,sz8);
			memset(&addTcurve,0,sizeof(TCurve));
			addTcurve.ncurvecolor=atoi(sz0);
			addTcurve.BcurvechannelNO=atoi(sz1);
			addTcurve.nlinenode=atoi(sz2);
			addTcurve.nlineline=atoi(sz3);
			addTcurve.nlinertu=atoi(sz4);
			addTcurve.Bdot=atoi(sz5);
			addTcurve.fcurveratio=atof(sz6);
			addTcurve.Bprecision=atoi(sz7);
			if (strlen(sz8)>0)
				strcpy(addTcurve.unit,sz8);

			zbVcurvearray.Add(addTcurve);
		}
	}
	return TRUE;
}
Example #2
0
INT_PTR CALLBACK GeneralPageDialogProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
  int updatestrings = 0;
  if (msg == WM_INITDIALOG) {
    wchar_t txt[20];
    GetPrivateProfileString(L"General", L"AutoFocus", L"0", txt, ARRAY_SIZE(txt), inipath);
    Button_SetCheck(GetDlgItem(hwnd,IDC_AUTOFOCUS), _wtoi(txt)?BST_CHECKED:BST_UNCHECKED);

    GetPrivateProfileString(L"General", L"Aero", L"2", txt, ARRAY_SIZE(txt), inipath);
    Button_SetCheck(GetDlgItem(hwnd,IDC_AERO), _wtoi(txt)?BST_CHECKED:BST_UNCHECKED);

    GetPrivateProfileString(L"General", L"InactiveScroll", L"1", txt, ARRAY_SIZE(txt), inipath);
    Button_SetCheck(GetDlgItem(hwnd,IDC_INACTIVESCROLL), _wtoi(txt)?BST_CHECKED:BST_UNCHECKED);

    GetPrivateProfileString(L"General", L"MDI", L"0", txt, ARRAY_SIZE(txt), inipath);
    Button_SetCheck(GetDlgItem(hwnd,IDC_MDI), _wtoi(txt)?BST_CHECKED:BST_UNCHECKED);

    HWND control = GetDlgItem(hwnd, IDC_LANGUAGE);
    ComboBox_ResetContent(control);
    if (l10n == &l10n_ini) {
      ComboBox_AddString(control, l10n->lang);
      ComboBox_SetCurSel(control, 0);
      ComboBox_Enable(control, FALSE);
    }
    else {
      ComboBox_Enable(control, TRUE);
      int i;
      for (i=0; i < ARRAY_SIZE(languages); i++) {
        ComboBox_AddString(control, languages[i]->lang);
        if (l10n == languages[i]) {
          ComboBox_SetCurSel(control, i);
        }
      }
    }

    Button_Enable(GetDlgItem(hwnd,IDC_ELEVATE), vista && !elevated);
  }
  else if (msg == WM_COMMAND) {
    int id = LOWORD(wParam);
    int event = HIWORD(wParam);
    HWND control = GetDlgItem(hwnd, id);
    int val = Button_GetCheck(control);
    wchar_t txt[10];

    if (id == IDC_AUTOFOCUS) {
      WritePrivateProfileString(L"General", L"AutoFocus", _itow(val,txt,10), inipath);
    }
    else if (id == IDC_AUTOSNAP && event == CBN_SELCHANGE) {
      val = ComboBox_GetCurSel(control);
      WritePrivateProfileString(L"General", L"AutoSnap", _itow(val,txt,10), inipath);
    }
    else if (id == IDC_AERO) {
      WritePrivateProfileString(L"General", L"Aero", _itow(val,txt,10), inipath);
    }
    else if (id == IDC_INACTIVESCROLL) {
      WritePrivateProfileString(L"General", L"InactiveScroll", _itow(val,txt,10), inipath);
    }
    else if (id == IDC_MDI) {
      WritePrivateProfileString(L"General", L"MDI", _itow(val,txt,10), inipath);
    }
    else if (id == IDC_LANGUAGE && event == CBN_SELCHANGE) {
      int i = ComboBox_GetCurSel(control);
      if (i == ARRAY_SIZE(languages)) {
        OpenUrl(L"https://stefansundin.github.io/altdrag/doc/translate.html");
        for (i=0; l10n != languages[i]; i++) {}
        ComboBox_SetCurSel(control, i);
      }
      else {
        l10n = languages[i];
        WritePrivateProfileString(L"General", L"Language", l10n->code, inipath);
        updatestrings = 1;
        UpdateStrings();
      }
    }
    else if (id == IDC_AUTOSTART) {
      SetAutostart(val, 0, 0);
      Button_Enable(GetDlgItem(hwnd,IDC_AUTOSTART_HIDE), val);
      Button_Enable(GetDlgItem(hwnd,IDC_AUTOSTART_ELEVATE), val && vista);
      if (!val) {
        Button_SetCheck(GetDlgItem(hwnd,IDC_AUTOSTART_HIDE), BST_UNCHECKED);
        Button_SetCheck(GetDlgItem(hwnd,IDC_AUTOSTART_ELEVATE), BST_UNCHECKED);
      }
    }
    else if (id == IDC_AUTOSTART_HIDE) {
      int elevate = Button_GetCheck(GetDlgItem(hwnd,IDC_AUTOSTART_ELEVATE));
      SetAutostart(1, val, elevate);
    }
    else if (id == IDC_AUTOSTART_ELEVATE) {
      int hide = Button_GetCheck(GetDlgItem(hwnd,IDC_AUTOSTART_HIDE));
      SetAutostart(1, hide, val);
      if (val) {
        // Don't nag if UAC is disabled, only check if elevated
        DWORD uac_enabled = 1;
        if (elevated) {
          DWORD len = sizeof(uac_enabled);
          HKEY key;
          RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System", 0, KEY_QUERY_VALUE, &key);
          RegQueryValueEx(key, L"EnableLUA", NULL, NULL, (LPBYTE)&uac_enabled, &len);
          RegCloseKey(key);
        }
        if (uac_enabled) {
          MessageBox(NULL, l10n->general_autostart_elevate_tip, APP_NAME, MB_ICONINFORMATION|MB_OK);
        }
      }
    }
    else if (id == IDC_ELEVATE && MessageBox(NULL,l10n->general_elevate_tip,APP_NAME,MB_ICONINFORMATION|MB_OK)) {
      wchar_t path[MAX_PATH];
      GetModuleFileName(NULL, path, ARRAY_SIZE(path));
      if ((INT_PTR)ShellExecute(NULL,L"runas",path,L"-config -multi",NULL,SW_SHOWNORMAL) > 32) {
        PostMessage(g_hwnd, WM_CLOSE, 0, 0);
      }
      else {
        MessageBox(NULL, l10n->general_elevation_aborted, APP_NAME, MB_ICONINFORMATION|MB_OK);
      }
      return;
    }
    UpdateSettings();
  }
  else if (msg == WM_NOTIFY) {
    LPNMHDR pnmh = (LPNMHDR) lParam;
    if (pnmh->code == PSN_SETACTIVE) {
      updatestrings = 1;

      // Autostart
      int autostart=0, hidden=0, elevated=0;
      CheckAutostart(&autostart, &hidden, &elevated);
      Button_SetCheck(GetDlgItem(hwnd,IDC_AUTOSTART), autostart?BST_CHECKED:BST_UNCHECKED);
      Button_SetCheck(GetDlgItem(hwnd,IDC_AUTOSTART_HIDE), hidden?BST_CHECKED:BST_UNCHECKED);
      Button_SetCheck(GetDlgItem(hwnd,IDC_AUTOSTART_ELEVATE), elevated?BST_CHECKED:BST_UNCHECKED);
      Button_Enable(GetDlgItem(hwnd,IDC_AUTOSTART_HIDE), autostart);
      Button_Enable(GetDlgItem(hwnd,IDC_AUTOSTART_ELEVATE), autostart && vista);
    }
  }
  if (updatestrings) {
    // Update text
    SetDlgItemText(hwnd, IDC_GENERAL_BOX,        l10n->general_box);
    SetDlgItemText(hwnd, IDC_AUTOFOCUS,          l10n->general_autofocus);
    SetDlgItemText(hwnd, IDC_AERO,               l10n->general_aero);
    SetDlgItemText(hwnd, IDC_INACTIVESCROLL,     l10n->general_inactivescroll);
    SetDlgItemText(hwnd, IDC_MDI,                l10n->general_mdi);
    SetDlgItemText(hwnd, IDC_AUTOSNAP_HEADER,    l10n->general_autosnap);
    SetDlgItemText(hwnd, IDC_LANGUAGE_HEADER,    l10n->general_language);
    SetDlgItemText(hwnd, IDC_AUTOSTART_BOX,      l10n->general_autostart_box);
    SetDlgItemText(hwnd, IDC_AUTOSTART,          l10n->general_autostart);
    SetDlgItemText(hwnd, IDC_AUTOSTART_HIDE,     l10n->general_autostart_hide);
    SetDlgItemText(hwnd, IDC_AUTOSTART_ELEVATE,  l10n->general_autostart_elevate);
    SetDlgItemText(hwnd, IDC_ELEVATE,            (elevated?l10n->general_elevated:l10n->general_elevate));
    SetDlgItemText(hwnd, IDC_AUTOSAVE,           l10n->general_autosave);

    // AutoSnap
    HWND control = GetDlgItem(hwnd, IDC_AUTOSNAP);
    ComboBox_ResetContent(control);
    ComboBox_AddString(control, l10n->general_autosnap0);
    ComboBox_AddString(control, l10n->general_autosnap1);
    ComboBox_AddString(control, l10n->general_autosnap2);
    ComboBox_AddString(control, l10n->general_autosnap3);
    wchar_t txt[10];
    GetPrivateProfileString(L"General", L"AutoSnap", L"0", txt, ARRAY_SIZE(txt), inipath);
    ComboBox_SetCurSel(control, _wtoi(txt));

    // Language
    control = GetDlgItem(hwnd, IDC_LANGUAGE);
    ComboBox_DeleteString(control, ARRAY_SIZE(languages));
    if (l10n == &en_US) {
      ComboBox_AddString(control, L"How can I help translate?");
    }
  }
  return FALSE;
}
Example #3
0
INT_PTR CALLBACK BlacklistPageDialogProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
  if (msg == WM_INITDIALOG) {
    wchar_t txt[1000];
    GetPrivateProfileString(L"Blacklist", L"ProcessBlacklist", L"", txt, ARRAY_SIZE(txt), inipath);
    SetDlgItemText(hwnd, IDC_PROCESSBLACKLIST, txt);
    GetPrivateProfileString(L"Blacklist", L"Blacklist", L"", txt, ARRAY_SIZE(txt), inipath);
    SetDlgItemText(hwnd, IDC_BLACKLIST, txt);
    GetPrivateProfileString(L"Blacklist", L"Snaplist", L"", txt, ARRAY_SIZE(txt), inipath);
    SetDlgItemText(hwnd, IDC_SNAPLIST, txt);
  }
  else if (msg == WM_COMMAND) {
    wchar_t txt[1000];
    int control = LOWORD(wParam);
    if (HIWORD(wParam) == EN_KILLFOCUS) {
      Edit_GetText(GetDlgItem(hwnd,control), txt, ARRAY_SIZE(txt));
      if (control == IDC_PROCESSBLACKLIST) {
        WritePrivateProfileString(L"Blacklist", L"ProcessBlacklist", txt, inipath);
      }
      else if (control == IDC_BLACKLIST) {
        WritePrivateProfileString(L"Blacklist", L"Blacklist", txt, inipath);
      }
      else if (control == IDC_SNAPLIST) {
        WritePrivateProfileString(L"Blacklist", L"Snaplist", txt, inipath);
      }
      UpdateSettings();
    }
    else if (HIWORD(wParam) == STN_CLICKED && control == IDC_FINDWINDOW) {
      // Get size of workspace
      int left = GetSystemMetrics(SM_XVIRTUALSCREEN);
      int top = GetSystemMetrics(SM_YVIRTUALSCREEN);
      int width = GetSystemMetrics(SM_CXVIRTUALSCREEN);
      int height = GetSystemMetrics(SM_CYVIRTUALSCREEN);

      // Create window
      WNDCLASSEX wnd = { sizeof(WNDCLASSEX), 0, CursorProc, 0, 0, g_hinst, NULL, NULL, (HBRUSH)(COLOR_WINDOW+1), NULL, APP_NAME"-find", NULL };
      wnd.hCursor = LoadImage(g_hinst, MAKEINTRESOURCE(IDI_FIND), IMAGE_CURSOR, 0, 0, LR_DEFAULTCOLOR);
      RegisterClassEx(&wnd);
      HWND findhwnd = CreateWindowEx(WS_EX_TOOLWINDOW|WS_EX_TOPMOST|WS_EX_LAYERED, wnd.lpszClassName, NULL, WS_POPUP, left, top, width, height, NULL, NULL, g_hinst, NULL);
      SetLayeredWindowAttributes(findhwnd, 0, 1, LWA_ALPHA); // Almost transparent
      ShowWindowAsync(findhwnd, SW_SHOWNA);

      // Hide icon
      ShowWindowAsync(GetDlgItem(hwnd,IDC_FINDWINDOW), SW_HIDE);
    }
  }
  else if (msg == WM_NOTIFY) {
    LPNMHDR pnmh = (LPNMHDR)lParam;
    if (pnmh->code == PSN_SETACTIVE) {
      // Update text
      SetDlgItemText(hwnd, IDC_BLACKLIST_BOX,           l10n->blacklist_box);
      SetDlgItemText(hwnd, IDC_PROCESSBLACKLIST_HEADER, l10n->blacklist_processblacklist);
      SetDlgItemText(hwnd, IDC_BLACKLIST_HEADER,        l10n->blacklist_blacklist);
      SetDlgItemText(hwnd, IDC_SNAPLIST_HEADER,         l10n->blacklist_snaplist);
      SetDlgItemText(hwnd, IDC_BLACKLIST_EXPLANATION,   l10n->blacklist_explanation);
      SetDlgItemText(hwnd, IDC_FINDWINDOW_BOX,          l10n->blacklist_findwindow_box);
      SetDlgItemText(hwnd, IDC_FINDWINDOW_EXPLANATION,  l10n->blacklist_findwindow_explanation);
    }
  }

  LinkProc(hwnd, msg, wParam, lParam);
  return FALSE;
}
//004c69a0	-> 100%
int CSkillAdditionInfo::Load(LPSTR lpszFileName)
{
	if( lpszFileName == NULL || strcmp(lpszFileName, "") == 0 )
	{
		LogAddTD("[Skill Addition Info] - File load error : File Name Error");
		return false;
	}
	// ----
#ifdef __CUSTOMS__
	int Token;
	this->Init();
	// ----
	SMDFile = fopen(gDirPath.GetNewPath(lpszFileName), "r");
	// ----
	if( SMDFile == 0 )
	{
		MsgBox(lMsg.Get(MSGGET(0, 112)), lpszFileName);
		return false;
	}
	// ----
	while(true) 
	{
		Token = GetToken();
		// ----
		if( Token == END || !strcmp(TokenString, "end") )
		{
			break;
		}
		else
		{
			int SkillID = TokenNumber;
			Token = GetToken();
			int Level	= TokenNumber;
			// ----
			if( Level < 1 )
			{
				Level = 1;
			}
			// ----
			this->m_SkillUseReqLevel[SkillID] = Level;
		}
	}
	// ----
	fclose(SMDFile);
	// ----
	char szFloat[256];
	// ----
	this->m_SoulBarrierDefenseStart				= GetPrivateProfileInt("SkillInfo", "SoulBarrierDefenseStart", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_SoulBarrierDefenseDiv1				= GetPrivateProfileInt("SkillInfo", "SoulBarrierDefenseDiv1", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_SoulBarrierDefenseDiv2				= GetPrivateProfileInt("SkillInfo", "SoulBarrierDefenseDiv2", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_SoulBarrierDefenseMax				= GetPrivateProfileInt("SkillInfo", "SoulBarrierDefenseMax", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_SoulBarrierTimeStart				= GetPrivateProfileInt("SkillInfo", "SoulBarrierTimeStart", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_SoulBarrierTimeDiv					= GetPrivateProfileInt("SkillInfo", "SoulBarrierTimeDiv", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_SoulBarrierTimeMax					= GetPrivateProfileInt("SkillInfo", "SoulBarrierTimeMax", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_WizardryEnchantDamageDiv			= GetPrivateProfileInt("SkillInfo", "WizardryEnchantDamageDiv", 600, gDirPath.GetNewPath(lpszFileName)); 
	GetPrivateProfileString("SkillInfo", "WizardryEnchantDamageFact", "10", szFloat, 5, gDirPath.GetNewPath(lpszFileName));
	sscanf(szFloat, "%f", &this->m_WizardryEnchantDamageFact);
	this->m_WizardryEnchantDamageMax			= GetPrivateProfileInt("SkillInfo", "WizardryEnchantDamageMax", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_WizardryEnchantTime					= GetPrivateProfileInt("SkillInfo", "WizardryEnchantTime", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_SwellLifeEffectStart				= GetPrivateProfileInt("SkillInfo", "SwellLifeEffectStart", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_SwellLifeEffectDiv1					= GetPrivateProfileInt("SkillInfo", "SwellLifeEffectDiv1", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_SwellLifeEffectDiv2					= GetPrivateProfileInt("SkillInfo", "SwellLifeEffectDiv2", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_SwellLifeEffectMax					= GetPrivateProfileInt("SkillInfo", "SwellLifeEffectMax", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_SwellLifeTimeStart					= GetPrivateProfileInt("SkillInfo", "SwellLifeTimeStart", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_SwellLifeTimeDiv					= GetPrivateProfileInt("SkillInfo", "SwellLifeTimeDiv", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_SwellLifeTimeMax					= GetPrivateProfileInt("SkillInfo", "SwellLifeTimeMax", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_ElfDefenseEffectFact				= GetPrivateProfileInt("SkillInfo", "ElfDefenseEffectFact", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_ElfDefenseEffectDiv					= GetPrivateProfileInt("SkillInfo", "ElfDefenseEffectDiv", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_ElfDefenseEffectMax					= GetPrivateProfileInt("SkillInfo", "ElfDefenseEffectMax", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_ElfDefenseTime						= GetPrivateProfileInt("SkillInfo", "ElfDefenseTime", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_ElfAttackEffectFact					= GetPrivateProfileInt("SkillInfo", "ElfAttackEffectFact", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_ElfAttackEffectDiv					= GetPrivateProfileInt("SkillInfo", "ElfAttackEffectDiv", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_ElfAttackEffectMax					= GetPrivateProfileInt("SkillInfo", "ElfAttackEffectMax", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_ElfAttackTime						= GetPrivateProfileInt("SkillInfo", "ElfAttackTime", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_CriticalDamageEffectDiv1			= GetPrivateProfileInt("SkillInfo", "CriticalDamageEffectDiv1", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_CriticalDamageEffectDiv2			= GetPrivateProfileInt("SkillInfo", "CriticalDamageEffectDiv2", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_CriticalDamageEffectMax				= GetPrivateProfileInt("SkillInfo", "CriticalDamageEffectMax", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_CriticalDamageTimeStart				= GetPrivateProfileInt("SkillInfo", "CriticalDamageTimeStart", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_CriticalDamageTimeDiv				= GetPrivateProfileInt("SkillInfo", "CriticalDamageTimeDiv", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_CriticalDamageTimeMax				= GetPrivateProfileInt("SkillInfo", "CriticalDamageTimeMax", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_BerserkerManaIncDiv					= GetPrivateProfileInt("SkillInfo", "BerserkerManaIncDiv", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_BerserkerLifeDecDiv					= GetPrivateProfileInt("SkillInfo", "BerserkerLifeDecDiv", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_BerserkerTimeStart					= GetPrivateProfileInt("SkillInfo", "BerserkerTimeStart", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_BerserkerTimeDiv					= GetPrivateProfileInt("SkillInfo", "BerserkerTimeDiv", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_BerserkerTimeMax					= GetPrivateProfileInt("SkillInfo", "BerserkerTimeMax", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_ReflectEffectStart					= GetPrivateProfileInt("SkillInfo", "ReflectEffectStart", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_ReflectEffectDiv					= GetPrivateProfileInt("SkillInfo", "ReflectEffectDiv", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_ReflectEffectMax					= GetPrivateProfileInt("SkillInfo", "ReflectEffectMax", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_ReflectTimeStart					= GetPrivateProfileInt("SkillInfo", "ReflectTimeStart", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_ReflectTimeDiv						= GetPrivateProfileInt("SkillInfo", "ReflectTimeDiv", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_ReflectTimeMax						= GetPrivateProfileInt("SkillInfo", "ReflectTimeMax", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_IgnoreDefenseEffectStart			= GetPrivateProfileInt("SkillInfo", "IgnoreDefenseEffectStart", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_IgnoreDefenseEffectSub				= GetPrivateProfileInt("SkillInfo", "IgnoreDefenseEffectSub", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_IgnoreDefenseEffectDiv				= GetPrivateProfileInt("SkillInfo", "IgnoreDefenseEffectDiv", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_IgnoreDefenseEffectMax				= GetPrivateProfileInt("SkillInfo", "IgnoreDefenseEffectMax", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_IgnoreDefenseTimeStart				= GetPrivateProfileInt("SkillInfo", "IgnoreDefenseTimeStart", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_IgnoreDefenseTimeDiv				= GetPrivateProfileInt("SkillInfo", "IgnoreDefenseTimeDiv", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_IgnoreDefenseTimeMax				= GetPrivateProfileInt("SkillInfo", "IgnoreDefenseTimeMax", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_IncreaseHealthEffectStart			= GetPrivateProfileInt("SkillInfo", "IncreaseHealthEffectStart", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_IncreaseHealthEffectSub				= GetPrivateProfileInt("SkillInfo", "IncreaseHealthEffectSub", 600, gDirPath.GetNewPath(lpszFileName)); 

	//this->m_IncreaseHealthEffectDiv				= GetPrivateProfileInt("SkillInfo", "IncreaseHealthEffectDiv", 600, gDirPath.GetNewPath(lpszFileName)); 
	char szTempEx[256] = { 0 };
	GetPrivateProfileString("SkillInfo", "DecTimePerAttackSpeed", "10.00", szTempEx, 256, gDirPath.GetNewPath(lpszFileName));
	this->m_IncreaseHealthEffectDiv = atof(szTempEx);

	this->m_IncreaseHealthEffectMax				= GetPrivateProfileInt("SkillInfo", "IncreaseHealthEffectMax", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_IncreaseHealthTimeStart				= GetPrivateProfileInt("SkillInfo", "IncreaseHealthTimeStart", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_IncreaseHealthTimeDiv				= GetPrivateProfileInt("SkillInfo", "IncreaseHealthTimeDiv", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_IncreaseHealthTimeMax				= GetPrivateProfileInt("SkillInfo", "IncreaseHealthTimeMax", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_IncreaseBlockEffectStart			= GetPrivateProfileInt("SkillInfo", "IncreaseBlockEffectStart", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_IncreaseBlockEffectSub				= GetPrivateProfileInt("SkillInfo", "IncreaseBlockEffectSub", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_IncreaseBlockEffectDiv				= GetPrivateProfileInt("SkillInfo", "IncreaseBlockEffectDiv", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_IncreaseBlockEffectMax				= GetPrivateProfileInt("SkillInfo", "IncreaseBlockEffectMax", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_IncreaseBlockTimeStart				= GetPrivateProfileInt("SkillInfo", "IncreaseBlockTimeStart", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_IncreaseBlockTimeDiv				= GetPrivateProfileInt("SkillInfo", "IncreaseBlockTimeDiv", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_IncreaseBlockTimeMax				= GetPrivateProfileInt("SkillInfo", "IncreaseBlockTimeMax", 600, gDirPath.GetNewPath(lpszFileName)); 
	// ----
	this->m_WeaknessEffectStartVsMob			= GetPrivateProfileInt("SkillInfo", "WeaknessEffectStartVsMob", 4, gDirPath.GetNewPath(lpszFileName));
	this->m_WeaknessEffectDivVsMob				= GetPrivateProfileInt("SkillInfo", "WeaknessEffectDivVsMob", 58, gDirPath.GetNewPath(lpszFileName));
	this->m_WeaknessEffectMaxVsMob				= GetPrivateProfileInt("SkillInfo", "WeaknessEffectMaxVsMob", 0, gDirPath.GetNewPath(lpszFileName));

	this->m_WeaknessTimeStartVsMob				= GetPrivateProfileInt("SkillInfo", "WeaknessTimeStartVsMob", 4, gDirPath.GetNewPath(lpszFileName));
	this->m_WeaknessTimeDivVsMob				= GetPrivateProfileInt("SkillInfo", "WeaknessTimeDivVsMob", 100, gDirPath.GetNewPath(lpszFileName));
	this->m_WeaknessTimeMaxVsMob				= GetPrivateProfileInt("SkillInfo", "WeaknessTimeMaxVsMob", 0, gDirPath.GetNewPath(lpszFileName));

	this->m_WeaknessEffectStartVsUser			= GetPrivateProfileInt("SkillInfo", "WeaknessEffectStartVsUser", 3, gDirPath.GetNewPath(lpszFileName));
	this->m_WeaknessEffectDivVsUser				= GetPrivateProfileInt("SkillInfo", "WeaknessEffectDivVsUser", 93, gDirPath.GetNewPath(lpszFileName));
	this->m_WeaknessEffectMaxVsUser				= GetPrivateProfileInt("SkillInfo", "WeaknessEffectMaxVsUser", 72, gDirPath.GetNewPath(lpszFileName));

	this->m_WeaknessTimeStartVsUser				= GetPrivateProfileInt("SkillInfo", "WeaknessTimeStartVsUser", 5, gDirPath.GetNewPath(lpszFileName));
	this->m_WeaknessTimeDivVsUser				= GetPrivateProfileInt("SkillInfo", "WeaknessTimeDivVsUser", 300, gDirPath.GetNewPath(lpszFileName));
	this->m_WeaknessTimeMaxVsUser				= GetPrivateProfileInt("SkillInfo", "WeaknessTimeMaxVsUser", 0, gDirPath.GetNewPath(lpszFileName));
	// ----
	this->m_InnovationEffectStartVsMob			= GetPrivateProfileInt("SkillInfo", "InnovationEffectStartVsMob", 20, gDirPath.GetNewPath(lpszFileName));
	this->m_InnovationEffectDivVsMob			= GetPrivateProfileInt("SkillInfo", "InnovationEffectDivVsMob", 90, gDirPath.GetNewPath(lpszFileName));
	this->m_InnovationEffectMaxVsMob			= GetPrivateProfileInt("SkillInfo", "InnovationEffectMaxVsMob", 0, gDirPath.GetNewPath(lpszFileName));

	this->m_InnovationTimeStartVsMob			= GetPrivateProfileInt("SkillInfo", "InnovationTimeStartVsMob", 4, gDirPath.GetNewPath(lpszFileName));
	this->m_InnovationTimeDivVsMob				= GetPrivateProfileInt("SkillInfo", "InnovationTimeDivVsMob", 100, gDirPath.GetNewPath(lpszFileName));
	this->m_InnovationTimeMaxVsMob				= GetPrivateProfileInt("SkillInfo", "InnovationTimeMaxVsMob", 0, gDirPath.GetNewPath(lpszFileName));

	this->m_InnovationEffectStartVsUser			= GetPrivateProfileInt("SkillInfo", "InnovationEffectStartVsUser", 12, gDirPath.GetNewPath(lpszFileName));
	this->m_InnovationEffectDivVsUser			= GetPrivateProfileInt("SkillInfo", "InnovationEffectDivVsUser", 110, gDirPath.GetNewPath(lpszFileName));
	this->m_InnovationEffectMaxVsUser			= GetPrivateProfileInt("SkillInfo", "InnovationEffectMaxVsUser", 0, gDirPath.GetNewPath(lpszFileName));

	this->m_InnovationTimeStartVsUser			= GetPrivateProfileInt("SkillInfo", "InnovationTimeStartVsUser", 5, gDirPath.GetNewPath(lpszFileName));
	this->m_InnovationTimeDivVsUser				= GetPrivateProfileInt("SkillInfo", "InnovationTimeDivVsUser", 300, gDirPath.GetNewPath(lpszFileName));
	this->m_InnovationTimeMaxVsUser				= GetPrivateProfileInt("SkillInfo", "InnovationTimeMaxVsUser", 0, gDirPath.GetNewPath(lpszFileName));	
	// ----

	this->m_SleepRateStartVsMob					= GetPrivateProfileInt("SkillInfo", "SleepRateStartVsMob", 20, gDirPath.GetNewPath(lpszFileName));
	this->m_SleepRateDivVsMob					= GetPrivateProfileInt("SkillInfo", "SleepRateDivVsMob", 30, gDirPath.GetNewPath(lpszFileName));
	this->m_SleepRateMaxVsMob					= GetPrivateProfileInt("SkillInfo", "SleepRateMaxVsMob", 0, gDirPath.GetNewPath(lpszFileName));

	this->m_SleepRateStartVsUser				= GetPrivateProfileInt("SkillInfo", "SleepRateStartVsUser", 15, gDirPath.GetNewPath(lpszFileName));
	this->m_SleepRateDivVsUser					= GetPrivateProfileInt("SkillInfo", "SleepRateDivVsUser", 37, gDirPath.GetNewPath(lpszFileName));
	this->m_SleepRateMaxVsUser					= GetPrivateProfileInt("SkillInfo", "SleepRateMaxVsUser", 0, gDirPath.GetNewPath(lpszFileName));

	this->m_SleepTimeStartVsMob					= GetPrivateProfileInt("SkillInfo", "SleepTimeStartVsMob", 5, gDirPath.GetNewPath(lpszFileName));
	this->m_SleepTimeDivVsMob					= GetPrivateProfileInt("SkillInfo", "SleepTimeDivVsMob", 100, gDirPath.GetNewPath(lpszFileName));
	this->m_SleepTimeMaxVsMob					= GetPrivateProfileInt("SkillInfo", "SleepTimeMaxVsMob", 0, gDirPath.GetNewPath(lpszFileName));

	this->m_SleepTimeStartVsUser				= GetPrivateProfileInt("SkillInfo", "SleepTimeStartVsUser", 4, gDirPath.GetNewPath(lpszFileName));
	this->m_SleepTimeDivVsUser					= GetPrivateProfileInt("SkillInfo", "SleepTimeDivVsUser", 250, gDirPath.GetNewPath(lpszFileName));
	this->m_SleepTimeMaxVsUser					= GetPrivateProfileInt("SkillInfo", "SleepTimeMaxVsUser", 0, gDirPath.GetNewPath(lpszFileName));
#endif
	// ----
	this->m_iInfinityArrowSkillTime				= GetPrivateProfileInt("SkillInfo", "InfinityArrowSkillTime", 600, gDirPath.GetNewPath(lpszFileName)); 
	this->m_iInfinityArrowUseLevel				= GetPrivateProfileInt("SkillInfo", "InfinityArrowUseLevel", 220, gDirPath.GetNewPath(lpszFileName)); 
	this->m_iInfinityArrowMPConsumptionPlus0	= GetPrivateProfileInt("SkillInfo", "InfinityArraowMPConsumptionPlus0", 0, gDirPath.GetNewPath(lpszFileName));
	this->m_iInfinityArrowMPConsumptionPlus1	= GetPrivateProfileInt("SkillInfo", "InfinityArraowMPConsumptionPlus1", 0, gDirPath.GetNewPath(lpszFileName));
	this->m_iInfinityArrowMPConsumptionPlus2	= GetPrivateProfileInt("SkillInfo", "InfinityArraowMPConsumptionPlus2", 0, gDirPath.GetNewPath(lpszFileName));
	this->m_iInfinityArrowMPConsumptionPlus3	= GetPrivateProfileInt("SkillInfo", "InfinityArraowMPConsumptionPlus3", 0, gDirPath.GetNewPath(lpszFileName));
	LogAddTD("[Skill Addition Info] [Infinity Arrow] Skill Time[%d], UseLevel[%d], Arrow MP Consumption +0[%d] +1[%d] +2[%d] +3[%d]", this->m_iInfinityArrowSkillTime, this->m_iInfinityArrowUseLevel, this->m_iInfinityArrowMPConsumptionPlus0, this->m_iInfinityArrowMPConsumptionPlus1, this->m_iInfinityArrowMPConsumptionPlus2, this->m_iInfinityArrowMPConsumptionPlus3);
	// ----
	this->m_bFireScreamSkill					= GetPrivateProfileInt("SkillInfo", "FireScreamSkill", 1, gDirPath.GetNewPath(lpszFileName));
	this->m_iFireScreamExplosionAttackDistance	= GetPrivateProfileInt("SkillInfo", "FireScreamExplosionAttackDistance", 1, gDirPath.GetNewPath(lpszFileName));
	this->m_iFireScreamExplosionRate			= GetPrivateProfileInt("SkillInfo", "FireScreamExplosionRate", 300, gDirPath.GetNewPath(lpszFileName));
	this->m_iFireScreamMaxAttackCountSameSerial = GetPrivateProfileInt("SkillInfo", "FireScreamMaxAttackCountSameSerial", 3, gDirPath.GetNewPath(lpszFileName));
	this->m_iFireScreamSerialInitCount			= GetPrivateProfileInt("SkillInfo", "FireScreamSerialInitCount", 100, gDirPath.GetNewPath(lpszFileName));
	this->m_bCheckFireScreamSerial				= GetPrivateProfileInt("SkillInfo", "CheckFireScreamSerial", 1, gDirPath.GetNewPath(lpszFileName));
	LogAddTD("[Skill Addition Info] [Fire Scream] Use(%d) : Explosion Distance(%d) - Rate(%d), MaxAttack_SameSerial(%d), SerialInitCount(%d), Check Serial(%d)", this->m_bFireScreamSkill, this->m_iFireScreamExplosionAttackDistance, this->m_iFireScreamExplosionRate, this->m_iFireScreamMaxAttackCountSameSerial, this->m_iFireScreamSerialInitCount, this->m_bCheckFireScreamSerial);
	// ----
	char szTemp[63]		= { 0 };
	BYTE byDefault		= 0;
	int n				= 1;
	// ----
	for( n = 1; n < 21; n++ )
	{
		wsprintf(szTemp, "SoulBarrierManaRate_Level%d", n);
		byDefault = 20 + n;
		this->m_nSoulBarrierManaRate_Level[n] = GetPrivateProfileInt("SkillInfo", szTemp, byDefault, gDirPath.GetNewPath(lpszFileName));
	}
	// ----
	char szTempLog[511]	= { 0 };
	wsprintf(szTempLog, "[Skill Addition Info] [SoulBarrier Strengrhen] BaseSkill (Level0):%d", this->m_nSoulBarrierManaRate_Level[0]);
	// ----
	for( n = 1; n < 21; n++ )
	{
		wsprintf(szTemp, ", Level%d : %d", n, this->m_nSoulBarrierManaRate_Level[n]);
		strcat(szTempLog, szTemp);
	}
	LogAddTD(szTempLog);
	// ----
	return true;
}
Example #5
0
void VNCOptions::Load(char *fname)
{
  for (int i = rfbEncodingRaw; i<= LASTENCODING; i++) {
    char buf[128];
    sprintf(buf, "use_encoding_%d", i);
    m_UseEnc[i] =   readInt(buf, m_UseEnc[i], fname) != 0;
  }
  m_PreferredEncoding =	readInt("preferred_encoding", m_PreferredEncoding,	fname);
  m_restricted =			readInt("restricted",		m_restricted,	fname) != 0 ;
  m_ViewOnly =			readInt("viewonly",			m_ViewOnly,		fname) != 0;
  m_NoStatus =			readInt("nostatus",			m_NoStatus,		fname) != 0;
  m_NoHotKeys =			readInt("nohotkeys",			m_NoHotKeys,	fname) != 0;
  m_ShowToolbar =			readInt("showtoolbar",			m_ShowToolbar,		fname) != 0;
  m_fAutoScaling =      readInt("AutoScaling",			m_fAutoScaling,		fname) != 0;
  m_FullScreen =			readInt("fullscreen",		m_FullScreen,	fname) != 0;
  autoDetect = readInt("autoDetect", autoDetect, fname) != 0;
  m_Use8Bit =				readInt("8bit",				m_Use8Bit,		fname);
  m_Shared =				readInt("shared",			m_Shared,		fname) != 0;
  m_SwapMouse =			readInt("swapmouse",		m_SwapMouse,	fname) != 0;
  m_DeiconifyOnBell =		readInt("belldeiconify",	m_DeiconifyOnBell, fname) != 0;
  m_Emul3Buttons =		readInt("emulate3",			m_Emul3Buttons, fname) != 0;
  m_JapKeyboard  =		readInt("JapKeyboard",			m_JapKeyboard, fname) != 0;
  m_Emul3Timeout =		readInt("emulate3timeout",	m_Emul3Timeout, fname);
  m_Emul3Fuzz =			readInt("emulate3fuzz",		m_Emul3Fuzz,    fname);
  m_DisableClipboard =	readInt("disableclipboard", m_DisableClipboard, fname) != 0;
  m_localCursor =			readInt("localcursor",		m_localCursor,	fname);
  m_scaling =			readInt("Scaling", m_scaling,  fname) != 0;
  m_fAutoScaling =		readInt("AutoScaling", m_fAutoScaling,  fname) != 0;
  m_scale_num =			readInt("scale_num",		m_scale_num,	fname);
  m_scale_den =			readInt("scale_den",		m_scale_den,	fname);
  // Tight specific
  m_requestShapeUpdates =	readInt("cursorshape",		m_requestShapeUpdates, fname) != 0;
  m_ignoreShapeUpdates =	readInt("noremotecursor",	m_ignoreShapeUpdates, fname) != 0;
  int level =				readInt("compresslevel",	-1,				fname);
  if (level != -1) {
	m_useCompressLevel = true;
	m_compressLevel = level;
  }
  level =					readInt("quality",			-1,				fname);
  if (level != -1) {
	m_enableJpegCompression = true;
	m_jpegQualityLevel = level;
  }
  // Modif sf@2002
  m_nServerScale =		readInt("ServerScale",		m_nServerScale,	fname);
  m_reconnectcounter =  readInt("Reconnect",		m_reconnectcounter,	fname);
  m_fEnableCache =		readInt("EnableCache",		m_fEnableCache,	fname) != 0;
  m_quickoption  =		readInt("QuickOption",		m_quickoption, fname);
  m_fUseDSMPlugin =		readInt("UseDSMPlugin",		m_fUseDSMPlugin, fname) != 0;
  m_fUseProxy =			readInt("UseProxy",			m_fUseProxy, fname) != 0;
  GetPrivateProfileString("options", "DSMPlugin", "NoPlugin", m_szDSMPluginFilename, MAX_PATH, fname);
  if (!g_disable_sponsor) g_disable_sponsor=readInt("sponsor",			g_disable_sponsor, fname) != 0;

  if (!g_disable_sponsor)
  {
  HKEY hRegKey;
		DWORD sponsor = 0;
		if ( RegCreateKey(HKEY_CURRENT_USER, SETTINGS_KEY_NAME, &hRegKey)  != ERROR_SUCCESS ) {
	        hRegKey = NULL;
		} else {
			DWORD sponsorsize = sizeof(sponsor);
			DWORD valtype=REG_DWORD;	
			if ( RegQueryValueEx( hRegKey,  "sponsor", NULL, &valtype, 
				(LPBYTE) &sponsor, &sponsorsize) == ERROR_SUCCESS) {
                g_disable_sponsor=sponsor ? true : false;
			}
			RegCloseKey(hRegKey);
		}
  }

  //m_autoReconnect =		readInt("AutoReconnect",	m_autoReconnect, fname) != 0;
  
  m_fExitCheck =		readInt("ExitCheck", m_fExitCheck,  fname) != 0; //PGM @ Advantig
  m_FTTimeout  = readInt("FileTransferTimeout", m_FTTimeout, fname);
  if (m_FTTimeout > 60)
      m_FTTimeout = 60; // cap at 1 minute

  m_keepAliveInterval  = readInt("KeepAliveInterval", m_keepAliveInterval, fname);
  if (m_keepAliveInterval >= (m_FTTimeout - KEEPALIVE_HEADROOM))
      m_keepAliveInterval = (m_FTTimeout  - KEEPALIVE_HEADROOM); 

}
Example #6
0
/**
 * 設定読み出し
 * @param[in] lpPath パス
 * @param[in] lpTitle タイトル
 * @param[in] lpTable 設定テーブル
 * @param[in] nCount 設定テーブル アイテム数
 */
void ini_read(LPCTSTR lpPath, LPCTSTR lpTitle, const PFTBL* lpTable, UINT nCount)
{
	const PFTBL* p = lpTable;
	const PFTBL* pTerminate = p + nCount;
	while (p < pTerminate)
	{
		TCHAR szWork[512];
		UINT32 val;
		switch (p->itemtype & PFTYPE_MASK)
		{
			case PFTYPE_STR:
				GetPrivateProfileString(lpTitle, p->item, static_cast<LPCTSTR>(p->value), static_cast<LPTSTR>(p->value), p->arg, lpPath);
				break;

			case PFTYPE_BOOL:
				GetPrivateProfileString(lpTitle, p->item,
									(*(static_cast<const UINT8*>(p->value))) ? str_true : str_false,
									szWork, NELEMENTS(szWork), lpPath);
				*(static_cast<UINT8*>(p->value)) = (!milstr_cmp(szWork, str_true)) ? 1 : 0;
				break;

			case PFTYPE_BITMAP:
				GetPrivateProfileString(lpTitle, p->item,
									(bitmapget(p->value, p->arg)) ? str_true : str_false,
									szWork, _countof(szWork), lpPath);
				bitmapset(p->value, p->arg, (milstr_cmp(szWork, str_true) == 0));
				break;

			case PFTYPE_BIN:
				GetPrivateProfileString(lpTitle, p->item, str_null, szWork, _countof(szWork), lpPath);
				binset(p->value, p->arg, szWork);
				break;

			case PFTYPE_SINT8:
			case PFTYPE_UINT8:
				val = GetPrivateProfileInt(lpTitle, p->item, *(static_cast<const UINT8*>(p->value)), lpPath);
				*(static_cast<UINT8*>(p->value)) = static_cast<UINT8>(val);
				break;

			case PFTYPE_SINT16:
			case PFTYPE_UINT16:
				val = GetPrivateProfileInt(lpTitle, p->item, *(static_cast<const UINT16*>(p->value)), lpPath);
				*(static_cast<UINT16*>(p->value)) = static_cast<UINT16>(val);
				break;

			case PFTYPE_SINT32:
			case PFTYPE_UINT32:
				val = GetPrivateProfileInt(lpTitle, p->item, *(static_cast<const UINT32*>(p->value)), lpPath);
				*(static_cast<UINT32*>(p->value)) = static_cast<UINT32>(val);
				break;

			case PFTYPE_HEX8:
				wsprintf(szWork, str_x, *(static_cast<const UINT8*>(p->value)));
				GetPrivateProfileString(lpTitle, p->item, szWork, szWork, _countof(szWork), lpPath);
				*(static_cast<UINT8*>(p->value)) = static_cast<UINT8>(milstr_solveHEX(szWork));
				break;

			case PFTYPE_HEX16:
				wsprintf(szWork, str_x, *(static_cast<const UINT16*>(p->value)));
				GetPrivateProfileString(lpTitle, p->item, szWork, szWork, _countof(szWork), lpPath);
				*(static_cast<UINT16*>(p->value)) = static_cast<UINT16>(milstr_solveHEX(szWork));
				break;

			case PFTYPE_HEX32:
				wsprintf(szWork, str_x, *(static_cast<const UINT32*>(p->value)));
				GetPrivateProfileString(lpTitle, p->item, szWork, szWork, _countof(szWork), lpPath);
				*(static_cast<UINT32*>(p->value)) = static_cast<UINT32>(milstr_solveHEX(szWork));
				break;

			case PFTYPE_ARGS16:
				GetPrivateProfileString(lpTitle, p->item, str_null, szWork, _countof(szWork), lpPath);
				inirdargs16(szWork, p);
				break;

			case PFTYPE_BYTE3:
				GetPrivateProfileString(lpTitle, p->item, str_null, szWork, _countof(szWork), lpPath);
				inirdbyte3(szWork, p);
				break;

			case PFTYPE_KB:
				GetPrivateProfileString(lpTitle, p->item, str_null, szWork, _countof(szWork), lpPath);
				inirdkb(szWork, p);
				break;
		}
		p++;
	}
}
// returns zero if successful
int ClientConnection::LoadConnection(char *fname, bool fFromDialog,bool default_file)
{
	// The Connection Profile ".vnc" has been required from Connection Session Dialog Box
	if (fFromDialog)
	{
		char tname[_MAX_FNAME + _MAX_EXT];
		ofnInit();
		ofn.hwndOwner = m_hSessionDialog;
		ofn.lpstrFile = fname;
		ofn.lpstrFileTitle = tname;
		ofn.Flags = OFN_HIDEREADONLY;

		// Open the FileSelection Dialog boxq
		if (GetOpenFileName(&ofn) == 0)
			return -1;
	}

	if (GetPrivateProfileString("connection", "host", "", m_host, MAX_HOST_NAME_LEN, fname) == 0) {
		//AaronP
//		MessageBox(m_hwnd, sz_K5, sz_K6, MB_ICONERROR | MB_OK | MB_SETFOREGROUND | MB_TOPMOST);
//		return -1;
		//EndAaronP
	}
	if ( (m_port = GetPrivateProfileInt("connection", "port", 0, fname)) == 0)
	{
		//
		//MessageBox(m_hwnd, sz_K7, sz_K6, MB_ICONERROR | MB_OK | MB_SETFOREGROUND | MB_TOPMOST);
		// in case options.vnc does not exist return to normal menu
		return -1;
	}

	GetPrivateProfileString("connection", "proxyhost", "", m_proxyhost, MAX_HOST_NAME_LEN, fname);
	m_proxyport = GetPrivateProfileInt("connection", "proxyport", 0, fname);
	m_fUseProxy = GetPrivateProfileInt("options", "UseProxy", 0, fname);

	char buf[32];
	m_encPasswd[0] = '\0';
	if (GetPrivateProfileString("connection", "password", "", buf, 32, fname) > 0) {
		for (int i = 0; i < MAXPWLEN; i++)	{
			int x = 0;
			sscanf(buf+i*2, "%2x", &x);
			m_encPasswd[i] = (unsigned char) x;
		}
	}

	// The Connection Profile ".vnc" has been required from Connection Session Dialog Box
	// Load the rest of params
	char optionfile[MAX_PATH];
	char *tempvar=NULL;
	tempvar = getenv( "TEMP" );
	if (tempvar) strcpy(optionfile,tempvar);
	else strcpy(optionfile,"");
	strcat(optionfile,"\\options.vnc");
	
//	if (fFromDialog)
	{
		m_opts.Load(fname);
		m_opts.Register();
	}
	//AaronP
	//else 
		if (strcmp(m_host, "") == 0 || 
			  strcmp(fname,optionfile)==0)
	{
		// Load the rest of params 
		strcpy(m_opts.m_proxyhost,m_proxyhost);
		m_opts.m_proxyport=m_proxyport;
		m_opts.m_fUseProxy=m_fUseProxy;
		m_opts.Load(fname);
		m_opts.Register();
		// Then display the session dialog to get missing params again
		SessionDialog sessdlg(&m_opts, this, m_pDSMPlugin); //sf@2002
		if (!sessdlg.DoDialog())
		{
			throw QuietException("");
		}
		_tcsncpy(m_host, sessdlg.m_host_dialog, MAX_HOST_NAME_LEN);
		m_port = sessdlg.m_port;
	
		_tcsncpy(m_proxyhost, sessdlg.m_proxyhost, MAX_HOST_NAME_LEN);
		m_proxyport = sessdlg.m_proxyport;
		m_fUseProxy = sessdlg.m_fUseProxy;

	};	
	//EndAaronP
	return 0;
}
Example #8
0
void
IniFile::ReadString(char *key1, char *key2,char *value,int valuesize)
{
	//vnclog.Print(LL_INTERR, VNCLOG("%s \n"),myInifile);
	GetPrivateProfileString(key1,key2, "",value,valuesize,myInifile);
}
Example #9
0
int main(int argc, char *argv[])
{
    HANDLE hCommPort;

    const char* config_file = ".\\serie.ini";

    unsigned int baud_rate = GetPrivateProfileInt("Configuracion",
                                                  "Velocidad",
                                                  9600,
                                                  config_file);

    unsigned int data_bits = GetPrivateProfileInt("Configuracion",
                                                  "BitsDatos",
                                                  8,
                                                  config_file);

    unsigned int stop_bits = GetPrivateProfileInt("Configuracion",
                                                  "BitsParada",
                                                  2,
                                                  config_file);

    char port_name[30];
    unsigned int _len = GetPrivateProfileString("Configuracion",
                                                "Puerto",
                                                "COM1",
                                                port_name,
                                                sizeof(port_name),
                                                config_file);

    char parity[20];
    unsigned int _parity_len = GetPrivateProfileString("Configuracion",
                                                       "Paridad",
                                                       "Sin paridad",
                                                       parity,
                                                       sizeof(parity),
                                                       config_file);

    printf("Datos: %d %d %d %s %s\n", baud_rate, data_bits, stop_bits, port_name, parity);

    //-- Abre el puerto serie
    hCommPort = serie_abrir(port_name, baud_rate, data_bits, stop_bits, parity);
    if (hCommPort == INVALID_HANDLE_VALUE)
    {
        perror("ERROR: No se puede acceder al puerto serie.");
        exit(2);
    }

    DWORD mask;
    if (!GetCommMask(hCommPort, &mask)) {
        perror("GetCommMask");
        exit(3);
    }

    if (!SetCommMask(hCommPort, mask | EV_ERR)) {
        perror("SetCommMask");
        exit(4);
    }

    printf("Pulse la tecla ESC para empezar a leer\n");
    while ( _getch() != ESC ) { /* Do nothing */ }

    //-- Crea el hilo encargado de la lectura de datos del puerto serie
    HANDLE hHiloLectura;
    DWORD idHiloLectura;
    hHiloLectura = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)HiloLectura, &hCommPort, 0, &idHiloLectura);
    if (hHiloLectura == NULL)
    {
        perror("ERROR: No se puede crear el hilo de lectura");
        exit(5);
    }

    printf("Pulse la tecla ESC para salir\n");

    //-- Bucle principal de escritura por el puerto serie
    char c;
    do
    {
        c = _getch();
        if (c != ESC) {
            serie_escribir(hCommPort, &c, sizeof(c));
        }
    } while (c != ESC);

    //-- Termina el hilo de lectura
    TerminateThread(hHiloLectura, 0);
    CloseHandle(hHiloLectura);

    //-- Cierra el puerto serie
    serie_cerrar(hCommPort);

    system("PAUSE");
    return 0;
}
void cConfigs::LoadConfigsInGS()
{								  	 

	#ifdef _GS
	DWORD *LoreGuard = (DWORD*)GUARD_SAY;
	char Lore[25];
	GetPrivateProfileString("Connect","GuardSay","Don't waste my time!",Lore,25,GreatDevelopGS);
	memset(&LoreGuard[0],0,25);
	memcpy(&LoreGuard[0],Lore,strlen(Lore));
	#endif

	DWORD dword;
	BYTE byte;

	dword = GetInt(300, 1000, 400,"LevelSettings", "MaxLevel", GreatDevelopCommon);
	*(unsigned int*) GS_MAX_LEVEL1 = dword;
	*(unsigned int*) GS_MAX_LEVEL2 = dword;
	*(unsigned int*) GS_MAX_LEVEL3 = dword;
	*(unsigned int*) GS_MAX_LEVEL4 = dword;
	*(unsigned int*) GS_MAX_LEVEL5 = dword;

	*(unsigned int*) GS_NOEXP_LEVEL = GetInt(401, 1001, 401,"LevelSettings", "MaxXPLevel", GreatDevelopCommon);
	*(unsigned int*) GS_MAX_MASTERLEVEL = GetInt(1, 400, 200,"LevelSettings", "MaxMasterLevel", GreatDevelopCommon);

	dword = GetInt(0, 360, 120,"ItemDropRates", "LootingTime", GreatDevelopItems);
	*(unsigned int*) GS_ITEM_TIME1 =	1000 * dword;
	*(unsigned int*) GS_ITEM_TIME2 =	1000 * dword;

	*(unsigned int*) GS_TRANSFORMATIONRING1 = GetInt(0, 600, 2,"TransformationRings","TransformRing1",GreatDevelopItems);
	*(unsigned int*) GS_TRANSFORMATIONRING2 = GetInt(0, 600, 7,"TransformationRings","TransformRing2",GreatDevelopItems);
	*(unsigned int*) GS_TRANSFORMATIONRING3 = GetInt(0, 600, 14,"TransformationRings","TransformRing3",GreatDevelopItems);
	*(unsigned int*) GS_TRANSFORMATIONRING4 = GetInt(0, 600, 8,"TransformationRings","TransformRing4",GreatDevelopItems);
	*(unsigned int*) GS_TRANSFORMATIONRING5 = GetInt(0, 600, 9,"TransformationRings","TransformRing5",GreatDevelopItems);
	*(unsigned int*) GS_TRANSFORMATIONRING6 = GetInt(0, 600, 41,"TransformationRings","TransformRing6",GreatDevelopItems);

	*(unsigned char*) GS_SUMMONORB1 = GetChar(0, 600, 26,"SummonOrbs","OrbSummon1",GreatDevelopItems);
	*(unsigned char*) GS_SUMMONORB2 = GetChar(0, 600, 32,"SummonOrbs","OrbSummon2",GreatDevelopItems);
	*(unsigned char*) GS_SUMMONORB3 = GetChar(0, 600, 21,"SummonOrbs","OrbSummon3",GreatDevelopItems);
	*(unsigned char*) GS_SUMMONORB4 = GetChar(0, 600, 20,"SummonOrbs","OrbSummon4",GreatDevelopItems);
	*(unsigned char*) GS_SUMMONORB5 = GetChar(0, 600, 10,"SummonOrbs","OrbSummon5",GreatDevelopItems);
	*(unsigned char*) GS_SUMMONORB6 = GetChar(0, 600, 150,"SummonOrbs","OrbSummon6",GreatDevelopItems);
	*(unsigned char*) GS_SUMMONORB7 =  GetChar(0, 600, 151,"SummonOrbs","OrbSummon7",GreatDevelopItems);

	
	*(unsigned int*) GS_BLESS_PRICE = GetInt(0, 2000000000, 6000000,"JewelPrices","JewelOfBlessPrice",GreatDevelopItems);
 	*(unsigned int*) GS_SOUL_PRICE = GetInt(0, 2000000000, 9000000,"JewelPrices","JewelOfSoulPrice",GreatDevelopItems);
	*(unsigned int*) GS_CHAOS_PRICE = GetInt(0, 2000000000, 810000,"JewelPrices","JewelOfChaosPrice",GreatDevelopItems);
	*(unsigned int*) GS_LIFE_PRICE =  GetInt(0, 2000000000, 45000000,"JewelPrices","JewelOfLifePrice",GreatDevelopItems);
	*(unsigned int*) GS_CREATION_PRICE = GetInt(0, 2000000000, 36000000,"JewelPrices","JewelOfCreationPrice",GreatDevelopItems);
	*(unsigned int*) GS_GUARDIAN_PRICE = GetInt(0, 2000000000, 60000000,"JewelPrices","JewelOfGuardianPrice",GreatDevelopItems);
	*(unsigned int*) GS_FRUITS_PRICE = GetInt(0, 2000000000, 33000000,"JewelPrices","FruitPrice",GreatDevelopItems);
	*(unsigned int*) GS_MONARCH_PRICE = GetInt(0, 2000000000, 750000,"JewelPrices","CrestOfMonarchPrice",GreatDevelopItems);
	*(unsigned int*) GS_FEATHER_PRICE = GetInt(0, 2000000000, 180000,"JewelPrices","LochsFeatherPrice",GreatDevelopItems);
	*(unsigned int*) GS_BLESSPOT_PRICE = GetInt(0, 2000000000, 900000,"JewelPrices","PotionOfBlessPrice",GreatDevelopItems);
	*(unsigned int*) GS_SOULPOT_PRICE = GetInt(0, 2000000000, 450000,"JewelPrices","PotionOfSoulPrice",GreatDevelopItems);
#ifdef _GS
	*(unsigned int*) GS_KUNDUN_ANC_PERCT = GetInt(0,10000,25,"Kundun","KundunDropAncRate",GreatDevelopItems);
	*(unsigned char*) GS_KUNDUN_ITEM_NUMB = GetChar(0,20,3,"Kundun","KundunDropItemCount",GreatDevelopItems);

	*(unsigned char*) GS_CCPLAYER = GetChar(0,20,2,"ChaosCastle","ChaosCastleMinPlayers",GreatDevelopEvents); 
	*(unsigned char*) GS_ITPLAYER = GetChar(0,20,4,"IllusionTemple","ItMinPlayers",GreatDevelopEvents); 
	/*
	*(unsigned char*) GS_CCREWARD1 = GetChar(0,15,14,"ChaosCastle","ChaosCastleRewardType1GroupID",GreatDevelopEvents) * 512 + GetChar(0,255,16,"ChaosCastle","ChaosCastleRewardType1IndexID",GreatDevelopEvents);
	*(unsigned char*) GS_CCREWARD2 = GetChar(0,15,14,"ChaosCastle","ChaosCastleRewardType2GroupID",GreatDevelopEvents) * 512 + GetChar(0,255,13,"ChaosCastle","ChaosCastleRewardType2IndexID",GreatDevelopEvents);
	*(unsigned char*) GS_CCREWARD3 = GetChar(0,15,14,"ChaosCastle","ChaosCastleRewardType3GroupID",GreatDevelopEvents) * 512 + GetChar(0,255,22,"ChaosCastle","ChaosCastleRewardType3IndexID",GreatDevelopEvents);
	*(unsigned char*) GS_CCREWARD4 = GetChar(0,15,14,"ChaosCastle","ChaosCastleRewardType4GroupID",GreatDevelopEvents) * 512 + GetChar(0,255,14,"ChaosCastle","ChaosCastleRewardType4IndexID",GreatDevelopEvents); 
	
	*(unsigned char*) GS_IT_GROUP_ID = GetChar(0,15,15,"IllusionTemple","ItDropGroup",GreatDevelopEvents);
	*(unsigned char*) GS_IT_DROP_ID = GetChar(0,255,12,"IllusionTemple","ItDropID",GreatDevelopEvents); 
	*(unsigned char*) GS_IT_ITEM_LVL = GetChar(0,15,0,"IllusionTemple","ItDropLevel",GreatDevelopEvents);
	*(unsigned char*) GS_IT_ITEM_SKL =  GetChar(0,1,0,"IllusionTemple","ItDropWithSkill",GreatDevelopEvents);
	*(unsigned char*) GS_IT_ITEM_LCK = GetChar(0,1,0,"IllusionTemple","ItDropWithLuck",GreatDevelopEvents);
	*(unsigned char*) GS_IT_ITEM_LIF = GetChar(0,7,0,"IllusionTemple","ItDropLifeAdd",GreatDevelopEvents);
	*(unsigned char*) GS_IT_ITEM_EXC = GetChar(0,63,0,"IllusionTemple","ItDropExcOpt",GreatDevelopEvents);
	*(unsigned char*) GS_IT_ITEM_ANC = GetChar(0,255,0,"IllusionTemple","ItDropAncOpt",GreatDevelopEvents); 

	*(unsigned char *) GS_BC_DROP_GROUP = GetChar(0,15,15,"BloodCastle","BcDropGroup",GreatDevelopEvents);
	*(unsigned char *) GS_BC_DROP_ID = GetChar(0,255,12,"BloodCastle","BcDropID",GreatDevelopEvents);
	*(unsigned char *) GS_BC_ITEM_LVL = GetChar(0,15,0,"BloodCastle","BcDropLevel",GreatDevelopEvents);
	*(unsigned char *) GS_BC_ITEM_SKL = GetChar(0,1,0,"BloodCastle","BcDropWithSkill",GreatDevelopEvents);
	*(unsigned char *) GS_BC_ITEM_LCK = GetChar(0,1,0,"BloodCastle","BcDropWithLuck",GreatDevelopEvents);
	*(unsigned char *) GS_BC_ITEM_LIF = GetChar(0,7,0,"BloodCastle","BcDropLifeAdd",GreatDevelopEvents);
	*(unsigned char *) GS_BC_ITEM_EXC = GetChar(0,63,0,"BloodCastle","BcDropExcOpt",GreatDevelopEvents);
	*(unsigned char *) GS_BC_ITEM_ANC = GetChar(0,255,0,"BloodCastle","BcDropAncOpt",GreatDevelopEvents); 

	*(unsigned char *) GS_WW_GROUP_ID = GetChar(0,15,13,"WhiteWizard","WizardDropGroup",GreatDevelopEvents);
	*(unsigned char *) GS_WW_DROP_ID = GetChar(0,255,20,"WhiteWizard","WizardDropItemID",GreatDevelopEvents);
	*(unsigned char *) GS_WW_ITEM_LVL = GetChar(0,15,0,"WhiteWizard","WizardDropLevel",GreatDevelopEvents);
	*(unsigned char *) GS_WW_ITEM_SKL = GetChar(0,1,0,"WhiteWizard","WizardDropWithSkill",GreatDevelopEvents);
	*(unsigned char *) GS_WW_ITEM_LCK = GetChar(0,1,0,"WhiteWizard","WizardDropWithLuck",GreatDevelopEvents);
	*(unsigned char *) GS_WW_ITEM_LIF = GetChar(0,7,0,"WhiteWizard","WizardDropLifeAdd",GreatDevelopEvents);
	*(unsigned char *) GS_WW_ITEM_EXC = GetChar(0,63,0,"WhiteWizard","WizardDropExcOpt",GreatDevelopEvents);
	*(unsigned char *) GS_WW_ITEM_ANC = GetChar(0,255,0,"WhiteWizard","WizardDropAncOpt",GreatDevelopEvents);
	*/
#endif
	*(unsigned char*) GS_GUILDALLIANCE = GetChar(0,50,20,"Guild","GuildAllianceMinPlayers",GreatDevelopCommon);

	*(unsigned char*) GS_PKBugLimitFix1 = GetChar(0, 1000, 20,"PKOptions", "PKKillLimit", GreatDevelopCommon);
    *(unsigned char*) GS_PKBugLimitFix2 = GetChar(0, 1000, 20,"PKOptions", "PKKillLimit", GreatDevelopCommon);
    *(unsigned char*) GS_PKBugLimitFix3 = GetChar(0, 1000, 20,"PKOptions", "PKKillLimit", GreatDevelopCommon);

	*(unsigned int*) GS_UDP_PORT = GetInt(0, 99999, 60006,"Connect","UDP-Port",GreatDevelopGS);

	*(unsigned char*) GS_SOUL_RATE_NORMAL = GetChar(0,100,60,"JewelRates","SoulSuccessRateNormal",GreatDevelopItems);
	*(unsigned char*) GS_SOUL_RATE_SPECIAL = GetChar(0,100,50,"JewelRates","SoulSuccessRateSpecial",GreatDevelopItems);
	*(unsigned char*) GS_SOUL_RATE_SOCKET = GetChar(0,100,40,"JewelRates","SoulSuccessRateSocket",GreatDevelopItems);
	*(unsigned char*) GS_SOUL_LUCK_ADD = GetChar(0,100,20,"JewelRates","SoulSuccessRateLuck",GreatDevelopItems);
	*(unsigned char*) GS_JOL_FAIL_RATE = GetChar(0,100,50,"JewelRates","LifeFailRate",GreatDevelopItems);

	byte = GetChar(0, 100, 60,"ChaosMachineMixes", "ChaosMix10Rate", GreatDevelopItems);
	*(unsigned char*)  GS_CM_MIX_10_NORMAL = byte;
	*(unsigned char*)  GS_CM_MIX_10_SPECIAL = byte;
	*(unsigned char*)  GS_CM_MIX_10_SOCKET = byte;
	byte = GetChar(0, 100, 50,"ChaosMachineMixes", "ChaosMix11_12Rate", GreatDevelopItems);
	*(unsigned char*)  GS_CM_MIX_11_12_NORMAL = byte;
	*(unsigned char*)  GS_CM_MIX_11_12_SPECIAL = byte;
	*(unsigned char*)  GS_CM_MIX_11_12_SOCKET = byte;
	byte = GetChar(0, 100, 40,"ChaosMachineMixes", "ChaosMix13Rate", GreatDevelopItems);
	*(unsigned char*)  GS_CM_MIX_13_NORMAL = byte;
	*(unsigned char*)  GS_CM_MIX_13_SPECIAL = byte;
	*(unsigned char*)  GS_CM_MIX_13_SOCKET = byte;
	byte = GetChar(0, 100, 75,"ChaosMachineMixes", "ChaosMixWithLuck", GreatDevelopItems);
	*(unsigned char*) GS_CM_MIX_10_LUCK = byte;
	*(unsigned char*) GS_CM_MIX_11_13_LUCK = byte;
	*(unsigned char*) GS_CM_MIX_LUCK_ADD = GetChar(0, 100, 20,"ChaosMachineMixes","ChaosMixRateIncreaseWithLuck",GreatDevelopItems);
	*(unsigned char*) DEFAULTMIXRATE = GetChar(0, 100, 45,"ChaosMachineMixes","ChaosMixDefaultRate",GreatDevelopItems);
	*(unsigned char*) GS_WINGLVL1MIX = GetChar(0, 100, 90,"ChaosMachineMixes","WingMixLvl1SuccessRate",GreatDevelopItems);
	*(unsigned char*) GS_WINGLVL2MIX = GetChar(0, 100, 90,"ChaosMachineMixes","WingMixLvl2SuccessRate",GreatDevelopItems);
	byte = GetChar(0, 100, 60,"ChaosMachineMixes","CondorMixSuccessRate",GreatDevelopItems);
	*(unsigned char *) GS_WINGLVL3MIX11 = byte;
	*(unsigned char *) GS_WINGLVL3MIX12 = byte;
	byte = GetChar(0, 100, 40,"ChaosMachineMixes","WingMixLvl3SuccessRate",GreatDevelopItems);
	*(unsigned char *) GS_WINGLVL3MIX21 = byte;
	*(unsigned char *) GS_WINGLVL3MIX22 = byte;

	*(unsigned char*) GS_SETITEMMIX1 = GetChar(0, 100, 80,"ChaosMachineMixes","380LevelMixSuccessRate",GreatDevelopItems);
	*(unsigned char*) GS_SETITEMMIX2 = GetChar(0, 100, 80,"ChaosMachineMixes","380LevelMixSuccessRate",GreatDevelopItems);
	*(unsigned int*) GS_DINO_MIX = GetInt(0, 100, 70,"ChaosMachineMixes","DinorantMixSuccessRate",GreatDevelopItems);
	
	*(unsigned int*) GS_DARK_HORSE = GetInt(0, 100, 60,"DLPets","DarkHorseMixSuccessRate",GreatDevelopItems);
	*(unsigned int*) GS_DARK_HORSE_PRICE = GetInt(0, 2000000000, 5000000,"DLPets","DarkHorseMixPrice",GreatDevelopItems);
   	*(unsigned int*) GS_DARK_SPIRIT = GetInt(0, 100, 60,"DLPets","DarkSpiritMixSuccessRate",GreatDevelopItems);
	*(unsigned int*) GS_DARK_SPIRIT_PRICE = GetInt(0, 2000000000, 1000000,"DLPets","DarkSpiritMixPrice",GreatDevelopItems);

	//Percentage for EXERate 0 - 100%
	int EXERate = GetInt(0, 100, 10,"ItemDropRates","ExcDropRate",GreatDevelopItems);
	*(unsigned int*) GS_EXC_DROP_RATE = 2000 - (20 * EXERate);
	//
	*(unsigned int*) GS_EXC_SKILL_RATE = GetInt(0, 100, 100,"ItemDropRates","ExcSkillDropRate",GreatDevelopItems);
	*(unsigned int*) GS_EXC_LUCK_RATE = GetInt(0, 100, 1,"ItemDropRates","ExcLuckDropRate",GreatDevelopItems);
	*(unsigned int*) GS_SKILL_RATE = GetInt(0, 100, 6,"ItemDropRates","NormalSkillDropRate",GreatDevelopItems);
	*(unsigned int*) GS_LUCK_RATE = GetInt(0, 100, 4,"ItemDropRates","NormalLuckDropRate",GreatDevelopItems);
	*(unsigned char*) GS_ANCREWARD_SKILL_RATE = GetChar(0, 100, 6,"ItemDropRates","AncientRewardSkillDropRate",GreatDevelopItems);
	*(unsigned char*) GS_ANCREWARD_LUCK_RATE = GetChar(0, 100, 4,"ItemDropRates","AncientRewardLuckDropRate",GreatDevelopItems);
	*(unsigned char*) GS_ANCRANDOM_SKILL_RATE = GetChar(0, 100, 6,"ItemDropRates","AncientRandomSkillDropRate",GreatDevelopItems);
	*(unsigned char*) GS_ANCRANDOM_LUCK_RATE = GetChar(0, 100, 4,"ItemDropRates","AncientRandomLuckDropRate",GreatDevelopItems);


	byte = GetChar(0, 20, 7,"LevelUpPoints","LevelUpPointsForDl",GreatDevelopCommon);
	*(unsigned char*) GS_LVL_UP_DL1 = byte;
	*(unsigned char*) GS_LVL_UP_DL2 = byte;
	*(unsigned char*) GS_LVL_UP_DL3 = byte;
	*(unsigned char*) GS_LVL_UP_DL4 = byte;
	*(unsigned char*) GS_LVL_UP_DL5 = byte;

	byte = GetChar(0, 20, 7,"LevelUpPoints","LevelUpPointsForMg",GreatDevelopCommon);
	*(unsigned char*) GS_LVL_UP_MG1 = byte;
	*(unsigned char*) GS_LVL_UP_MG2 = byte;
	*(unsigned char*) GS_LVL_UP_MG3 = byte;
	*(unsigned char*) GS_LVL_UP_MG4 = byte;
	*(unsigned char*) GS_LVL_UP_MG5 = byte;

	byte = GetChar(0, 20, 5,"LevelUpPoints","LevelUpPointsForDkElfDwSum",GreatDevelopCommon);
	*(unsigned char*) GS_LVL_UP_NORMAL1 = byte;
	*(unsigned char*) GS_LVL_UP_NORMAL2 = byte;
	*(unsigned char*) GS_LVL_UP_NORMAL3 = byte;
	*(unsigned char*) GS_LVL_UP_NORMAL4 = byte;
	*(unsigned char*) GS_LVL_UP_NORMAL5 = byte;

	byte = GetChar(0, 5, 1,"LevelUpPoints","ExtraPointsAfterMarlonQuest",GreatDevelopCommon);
	*(unsigned char*) GS_LVL_UP_QUEST1 = byte;
	*(unsigned char*) GS_LVL_UP_QUEST2 = byte;
	*(unsigned char*) GS_LVL_UP_QUEST3 = byte;
	*(unsigned char*) GS_LVL_UP_QUEST4 = byte;
	*(unsigned char*) GS_LVL_UP_QUEST5 = byte;

	*(unsigned char*) GS_ML_POINTS = GetChar(0, 20, 1,"LevelUpPoints","MasterlvlPoints",GreatDevelopCommon);

	*(unsigned int *) GS_TWISTINGSLASH_USELV = GetInt(0,5000,80,"SkillLevel", "TwistingSlashMinLevel", GreatDevelopSkills);
	*(unsigned int *) GS_RAGEFULBLOW_USELV = GetInt(0,5000,170,"SkillLevel", "RagefulBlowMinLevel", GreatDevelopSkills);
	*(unsigned int *) GS_DEATHSTAB_USELV = GetInt(0,5000,160,"SkillLevel", "DeathStabMinLevel", GreatDevelopSkills);
	*(unsigned int *) GS_IMPALE_USELV = GetInt(0,5000,25,"SkillLevel", "ImapleMinLevel", GreatDevelopSkills) ;
	*(unsigned int *) GS_INNERSTRENGTH_USELV = GetInt(0,5000,120,"SkillLevel", "GreaterFortitudeMinLevel", GreatDevelopSkills) ;
	*(unsigned int *) GS_PENETRATION_USELV = GetInt(0,5000,130,"SkillLevel", "PenetrationMinLevel", GreatDevelopSkills) ;

	*(unsigned int *) GS_MSNORMAL01 = GetInt(0,10000,250,"ManaShield", "ManaShieldAgiNormal", GreatDevelopSkills) ;
	*(unsigned int *) GS_MSNORMAL02 = GetInt(0,10000,200,"ManaShield", "ManaShieldEneNormal", GreatDevelopSkills) ;
	*(unsigned int *) GS_MSMASTER01 = GetInt(0,10000,50,"ManaShield", "ManaShieldAgiMaster", GreatDevelopSkills) ;
	*(unsigned int *) GS_MSMASTER02 = GetInt(0,10000,50,"ManaShield", "ManaShieldEneMaster", GreatDevelopSkills) ; 

	*(unsigned int *) NormalManaShieldTime1 = GetInt(0,10000,40,"ManaShield", "ManaShieldTime", GreatDevelopSkills) ;
	*(unsigned int *) MasterManaShieldTime2 = GetInt(0,10000,40,"ManaShield", "ManaShieldTimeMaster", GreatDevelopSkills) ;


	dword =  GetInt(0,5000,150,"GreatFortitude", "GreatFortitudeVitNormal", GreatDevelopSkills);
	*(unsigned int *) NormalGreatForitiuteVit01 = dword;
	*(unsigned int *) NormalGreatForitiuteVit02 = dword;
	*(unsigned int *) NormalGreatForitiuteVit03 = dword;
	*(unsigned int *) GS_GFNORMAL02 = GetInt(0,5000,100,"GreatFortitude", "GreatFortitudeEneNormal", GreatDevelopSkills) ;

	dword =  GetInt(0,5000,150,"GreatFortitude", "GreatFortitudeVitMaster", GreatDevelopSkills);
	*(unsigned int *) MasterGreatForitiuteVit01 = dword;
	*(unsigned int *) MasterGreatForitiuteVit02 = dword;
	*(unsigned int *) MasterGreatForitiuteVit03 = dword;
	*(unsigned int *) GS_GFMASTER02 = GetInt(0,5000,100,"GreatFortitude", "GreatFortitudeEneMaster", GreatDevelopSkills) ;

	*(unsigned int *) NormalGreatForitiuteTime = GetInt(0,10000,10,"GreatFortitude", "GreatFortitudeTime", GreatDevelopSkills) ;
	*(unsigned int *) MasterGreatForitiuteTime = GetInt(0,10000,10,"GreatFortitude", "GreatFortitudeMaster", GreatDevelopSkills) ;


	*(unsigned int*) GS_BERSERKER_DIV1 = GetInt(0,5000,20,"Berserker","BerserkerDiv1",GreatDevelopSkills);
	*(unsigned int*) GS_BERSERKER_DIV2 = GetInt(0,5000,30,"Berserker","BerserkerDiv2",GreatDevelopSkills);
	*(unsigned int*) GS_BERSERKER_DIV3 = GetInt(0,5000,60,"Berserker","BerserkerDiv3",GreatDevelopSkills);
	*(unsigned int*) GS_DAMAGEREF_DIV1 = GetInt(0,5000,42,"DamageRef","DamageRefDiv1",GreatDevelopSkills);
	*(unsigned int*) GS_DAMAGEREF_DIV2 = GetInt(0,5000,25,"DamageRef","DamageRefDiv2",GreatDevelopSkills);

	*(unsigned int*) GS_CRITICALDMG_COMMAND = GetInt(0,5000,25,"CriticalDmg","CriticalDmgLeaderShip",GreatDevelopSkills);
	*(unsigned int*) GS_CRITICALDMG_ENERGY = GetInt(0,5000,30,"CriticalDmg","CriticalDmgEnergy",GreatDevelopSkills);
	*(unsigned int*) GS_CRITICALDMG_TIME = GetInt(0,5000,10,"CriticalDmg","CriticalDmgTime",GreatDevelopSkills);

	*(unsigned int*) MaxZen  = GetInt(0, 2000000000, 2000000000,"MaximumZen", "MaxZenInBag", GreatDevelopCommon);

	dword = GetInt(0, 2000000000, 1000000000,"MaximumZen", "MaxZenInVault", GreatDevelopCommon);
	*(unsigned int*) MaxZen1 = dword;
	*(unsigned int*) MaxZen2 = dword;
	*(unsigned int*) MaxZen3 = dword;

	*(unsigned int *) GS_PARTYEXP_2_NORMAL = GetInt(0,5000,160,"PartyExp","NormalParty2Exp",GreatDevelopCommon);
	*(unsigned int *) GS_PARTYEXP_3_NORMAL = GetInt(0,5000,180,"PartyExp","NormalParty3Exp",GreatDevelopCommon);
	*(unsigned int *) GS_PARTYEXP_4_NORMAL = GetInt(0,5000,200,"PartyExp","NormalParty4Exp",GreatDevelopCommon);
	*(unsigned int *) GS_PARTYEXP_5_NORMAL = GetInt(0,5000,220,"PartyExp","NormalParty5Exp",GreatDevelopCommon);
	*(unsigned int *) GS_PARTYEXP_3_SET = GetInt(0,5000,230,"PartyExp","SetParty3Exp",GreatDevelopCommon);
	*(unsigned int *) GS_PARTYEXP_4_SET = GetInt(0,5000,270,"PartyExp","SetParty4Exp",GreatDevelopCommon);
	*(unsigned int *) GS_PARTYEXP_5_SET  = GetInt(0,5000,300,"PartyExp","SetParty5Exp",GreatDevelopCommon);
#ifdef _GS
	*(unsigned int*) GS_DS_PARTYEXP_2 = GetInt(0,5000,160,"DevilSquare","DevilSquarePartyExp2Players",GreatDevelopEvents);
	*(unsigned int*) GS_DS_PARTYEXP_3 = GetInt(0,5000,180,"DevilSquare","DevilSquarePartyExp3Players",GreatDevelopEvents);
	*(unsigned int*) GS_DS_PARTYEXP_4 = GetInt(0,5000,200,"DevilSquare","DevilSquarePartyExp4Players",GreatDevelopEvents);
	*(unsigned int*) GS_DS_PARTYEXP_5 = GetInt(0,5000,220,"DevilSquare","DevilSquarePartyExp5Players",GreatDevelopEvents);
	*(unsigned int*) GS_DS_PARTYDIFFEXP_3 = GetInt(0,5000,230,"DevilSquare","DevilSquareSetPartyExp3Players",GreatDevelopEvents);
	*(unsigned int*) GS_DS_PARTYDIFFEXP_4 = GetInt(0,5000,270,"DevilSquare","DevilSquareSetPartyExp4Players",GreatDevelopEvents);
	*(unsigned int*) GS_DS_PARTYDIFFEXP_5 = GetInt(0,5000,300,"DevilSquare","DevilSquareSetPartyExp5Players",GreatDevelopEvents);
#endif
#ifdef _GS_CS
	*(unsigned int*) GSCS_LOT_MAXPRICE = GetInt(0,1000000000,300000,"CastleSiege","CSLandOfTrialMaxPayment",GreatDevelopEvents);
	*(unsigned char*) GSCS_LORDMIX_MAXUSE  = GetChar(0,5000,0,"CastleSiege","CSLordMixMaxUsePerDay",GreatDevelopEvents);

	*(unsigned char*) GSCS_CRYWOLF_REWARD_ELF = GetChar(0,15,14,"CryWolf","CrywolfAltarElfRewardIndexID",GreatDevelopEvents) * 512 + GetChar(0,255,13,"CryWolf","CrywolfAltarElfRewardGroupID",GreatDevelopEvents);
	*(unsigned char*) GSCS_CRYWOLF_REWARD_TOP5 = GetChar(0,15,14,"CryWolf","CrywolfTop5RewardIndexID",GreatDevelopEvents) * 512 + GetChar(0,255,13,"CryWolf","CrywolfTop5RewardGroupID",GreatDevelopEvents);
	
	dword = GetInt(0,1000000000,200000000,"CastleSiege","CSSeniorMaxCash",GreatDevelopEvents);
	*(unsigned int*) GSCS_SENIOR_MAXZEN1 = dword;
	*(unsigned int*) GSCS_SENIOR_MAXZEN2 = dword;
#endif 
}	
Example #11
0
LPSTR EXPORT GetHackProfileStringEx(LPCSTR lpHackName, LPCSTR lpSectionName, LPCSTR lpKeyName, DWORD& cSize)
{
	bool		bFileFound = false;
	LPSTR		lpFileName = new char[MAX_PATH];
	LPCSTR		lpDefault="";
	LPSTR		lpReturnedString = NULL;

	LinkedItem*	li;
	CLIENTINFOSTRUCT* cds;

	sprintf( lpFileName, "%s\\%s.ini", si->PluginDirectory, lpHackName );

	// Check if the file exists
	if( _access(lpFileName, 0) )
	{
		// Check in the dir of the loaded modules
		li=ClientList.GetFirstItem();
		for( int i=0; i<ClientList.GetItemCount(); i++ )
		{	
			cds=(CLIENTINFOSTRUCT*)li->lpData;
			sprintf( lpFileName, "%s\\%s.ini", cds->pDir, lpHackName );
			if ( !_access(lpFileName, 0) )
			{
				bFileFound = true;
				break;
			}
			li=ClientList.GetNextItem(li);
		}

		if( !bFileFound )
		{
			char t[1024];
			sprintf(t, "Unable to open ini-file: ÿc4%s", lpFileName);
			fep->GamePrintError(t);
			delete lpFileName;
			return NULL;
		}
	}

	// Try getting the data in 1024-byte increments
	DWORD	alloc=0;
	DWORD	allocStep = 1024;
	int		SizeOffset;

	cSize = 0;

	if( !lpSectionName || !lpKeyName )
		SizeOffset = 2;
	else
		SizeOffset = 1;

	while (TRUE)
	{
		alloc+=allocStep;
		lpReturnedString = new char[alloc];
		if ( (cSize = GetPrivateProfileString(lpSectionName, lpKeyName, lpDefault, lpReturnedString, alloc, lpFileName)) < (alloc - SizeOffset) )
			break;
		delete lpReturnedString;
	}
	delete lpFileName;


	szBufferList.AddItem( lpReturnedString );		// Buffer used to delete this string
												// when Server exits

	return lpReturnedString;
}
void cConfigs::LoadNotice()
{	
	ConnectInfo					= GetInt(0, 1,					1,		"Connect",		"ConnectInfo",					GreatDevelopGS);
	GetPrivateProfileString("Connect","ConnectNotice","Powered by GreatDevelop 1.0.2",ConnectNotice,sizeof(ConnectNotice),GreatDevelopGS); 
	Log.CheckProcent(ConnectNotice);	 
} 
Example #13
0
void InitSettings(void)
{
	char fname[_MAX_FNAME+MAX_PATH], scriptPath[_MAX_PATH], defaultStarter[_MAX_FNAME], defaultGame[_MAX_FNAME],
		 debug[6], quitOnHostile[6], quitOnError[6], maxGameTime[6], gameTimeout[6],
		 startAtMenu[6], disableCache[6], memUsage[6], gamePrint[6], useProfilePath[6], logConsole[6];

	sprintf_s(fname, sizeof(fname), "%sd2bs.ini", Vars.szPath);

	GetPrivateProfileString("settings", "ScriptPath", "scripts", scriptPath, _MAX_PATH, fname);
	GetPrivateProfileString("settings", "DefaultGameScript", "default.dbj", defaultGame, _MAX_FNAME, fname);
	GetPrivateProfileString("settings", "DefaultStarterScript", "starter.dbj", defaultStarter, _MAX_FNAME, fname);
	GetPrivateProfileString("settings", "MaxGameTime", "0", maxGameTime, 6, fname);
	GetPrivateProfileString("settings", "Debug", "false", debug, 6, fname);
	GetPrivateProfileString("settings", "QuitOnHostile", "false", quitOnHostile, 6, fname);
	GetPrivateProfileString("settings", "QuitOnError", "false", quitOnError, 6, fname);
	GetPrivateProfileString("settings", "StartAtMenu", "true", startAtMenu, 6, fname);
	GetPrivateProfileString("settings", "DisableCache", "true", disableCache, 6, fname);
	GetPrivateProfileString("settings", "MemoryLimit", "50", memUsage, 6, fname);
	GetPrivateProfileString("settings", "UseGamePrint", "false", gamePrint, 6, fname);
	GetPrivateProfileString("settings", "GameReadyTimeout", "5", gameTimeout, 6, fname);
	GetPrivateProfileString("settings", "UseProfileScript", "false", useProfilePath, 6, fname);
	GetPrivateProfileString("settings", "LogConsoleOutput", "false", logConsole, 6, fname);

	sprintf_s(Vars.szScriptPath, _MAX_PATH, "%s%s", Vars.szPath, scriptPath);
	strcpy_s(Vars.szStarter, _MAX_FNAME, defaultStarter);
	strcpy_s(Vars.szDefault, _MAX_FNAME, defaultGame);

	Vars.dwGameTime = GetTickCount();
	Vars.dwMaxGameTime = abs(atoi(maxGameTime) * 1000);
	Vars.dwGameTimeout = abs(atoi(gameTimeout) * 1000);

	Vars.bQuitOnHostile = StringToBool(quitOnHostile);
	Vars.bQuitOnError = StringToBool(quitOnError);
	Vars.bStartAtMenu = StringToBool(startAtMenu);
	Vars.bDisableCache = StringToBool(disableCache);
	Vars.bUseGamePrint = StringToBool(gamePrint);
	Vars.bUseProfileScript = StringToBool(useProfilePath);
	Vars.bLogConsole = StringToBool(logConsole);

	Vars.dwMemUsage = abs(atoi(memUsage));
	if(Vars.dwMemUsage < 1)
		Vars.dwMemUsage = 50;
	Vars.dwMemUsage *= 1024*1024;
	Vars.oldWNDPROC = NULL;
}
Example #14
0
// Uploads the PNG file to Gyazo
BOOL uploadFile(HWND hwnd, LPCTSTR fileName, BOOL isPng)
{
	const int nSize = 256;
	LPCTSTR DEFAULT_UPLOAD_SERVER = _T("upload.gyazo.com");
	LPCTSTR DEFAULT_UPLOAD_PATH   = _T("/upload.cgi");
	LPCTSTR DEFAULT_UPLOAD_TOKEN = _T("");
	//LPCTSTR DEFAULT_USER_AGENT    = _T("User-Agent: Gyazowin/1.0\r\n");
	const int DEFAULT_UPLOAD_SERVER_PORT = INTERNET_DEFAULT_HTTP_PORT;

	TCHAR upload_server[nSize];
	TCHAR upload_path[nSize];
	TCHAR upload_token[nSize];
	//TCHAR ua[nSize];
	lstrcpy(upload_server, DEFAULT_UPLOAD_SERVER);
	lstrcpy(upload_path, DEFAULT_UPLOAD_PATH);
	lstrcpy(upload_token, DEFAULT_UPLOAD_TOKEN);
	//lstrcpy(ua, DEFAULT_USER_AGENT);
	int upload_server_port = DEFAULT_UPLOAD_SERVER_PORT;

	TCHAR runtime_path[MAX_PATH+1];
	TCHAR runtime_dirname[MAX_PATH+1];
	TCHAR config_file[MAX_PATH+1];
	if (0 != ::GetModuleFileName(NULL, runtime_path, MAX_PATH)) {
		TCHAR tmp[MAX_PATH+1];
		_tsplitpath_s(runtime_path, tmp, runtime_dirname, tmp, tmp);
	}
	lstrcpy(config_file, runtime_dirname);
	lstrcat(config_file, _T("\\gyazo.ini"));
	if (PathFileExists(config_file)) {
		LPCTSTR SECTION_NAME = _T("gyazo");
		GetPrivateProfileString(SECTION_NAME, _T("server"), DEFAULT_UPLOAD_SERVER, upload_server, sizeof(upload_server), config_file);
		GetPrivateProfileString(SECTION_NAME, _T("path"), DEFAULT_UPLOAD_PATH, upload_path, sizeof(upload_path), config_file);
		GetPrivateProfileString(SECTION_NAME, _T("token"), DEFAULT_UPLOAD_TOKEN, upload_token, sizeof(upload_token), config_file);
		//GetPrivateProfileString(SECTION_NAME, _T("user_agent"), DEFAULT_USER_AGENT, ua, sizeof(ua), config_file);
		upload_server_port = GetPrivateProfileInt(SECTION_NAME, _T("port"), DEFAULT_UPLOAD_SERVER_PORT, config_file);
	}

	const char*  sBoundary = "----BOUNDARYBOUNDARY----";		// boundary
	const char   sCrLf[]   = { 0xd, 0xa, 0x0 };					// 改行(CR+LF)
	TCHAR szHeader[200];

	StringCchPrintf(szHeader, 200, TEXT("Auth-Token: %s\r\nContent-type: multipart/form-data; boundary=----BOUNDARYBOUNDARY----"), upload_token);

	std::ostringstream	buf;	// 送信メッセージ

	wchar_t fname[_MAX_FNAME];
	wchar_t ext[_MAX_EXT];
	_wsplitpath(fileName, NULL, NULL, fname, ext );
	std::string data = (isPng) ? "imagedata" : "data";
	LPCTSTR file = (isPng) ? _T("gyazo") : wcsncat(fname, ext, _MAX_FNAME);
	size_t size = wcstombs(NULL, file, 0);
	char* CharStr = new char[size + 1];
	wcstombs(CharStr, file, size + 1);

	// -- "imagedata" part
	buf << "--";
	buf << sBoundary;
	buf << sCrLf;
	buf << "content-disposition: form-data; name=\"";
	buf << data;
	buf << "\"; filename=\"";
	buf << CharStr;
	buf << "\"";
	buf << sCrLf;
	//buf << "Content-type: image/png";	// 一応
	//buf << sCrLf;
	buf << sCrLf;

	// 本文: PNG ファイルを読み込む
	std::ifstream png;
	png.open(fileName, std::ios::binary);
	if (png.fail()) {
		MessageBox(hwnd, _T("PNG open failed"), szTitle, MB_ICONERROR | MB_OK);
		png.close();
		return FALSE;
	}
	buf << png.rdbuf();		// read all & append to buffer
	png.close();

	// 最後
	buf << sCrLf;
	buf << "--";
	buf << sBoundary;
	buf << "--";
	buf << sCrLf;

	// メッセージ完成
	std::string oMsg(buf.str());

	// WinInet を準備 (proxy は 規定の設定を利用)
	HINTERNET hSession    = InternetOpen(_T("Gyazowin/1.0"), 
		INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
	if(NULL == hSession) {
		LastErrorMessageBox(hwnd, _T("Cannot configure wininet."));
		return FALSE;
	}
	
	// 接続先
	HINTERNET hConnection = InternetConnect(hSession, 
		upload_server, upload_server_port,
		NULL, NULL, INTERNET_SERVICE_HTTP, 0, NULL);
	if(NULL == hConnection) {
		LastErrorMessageBox(hwnd, _T("Cannot initiate connection."));
		InternetCloseHandle(hSession);
		return FALSE;
	}

	// 要求先の設定
	HINTERNET hRequest    = HttpOpenRequest(hConnection,
		_T("POST"), upload_path, NULL,
		NULL, NULL, INTERNET_FLAG_DONT_CACHE | INTERNET_FLAG_RELOAD, NULL);
	if(NULL == hRequest) {
		LastErrorMessageBox(hwnd, _T("Cannot compose post request."));
		InternetCloseHandle(hConnection);
		InternetCloseHandle(hSession);
		return FALSE;
	}
	
	// 要求を送信
	BOOL bSuccess = FALSE;
	if (HttpSendRequest(hRequest,
                    szHeader,
					lstrlen(szHeader),
                    (LPVOID)oMsg.c_str(),
					(DWORD) oMsg.length()))
	{
		// 要求は成功
		
		DWORD resLen = 8;
		TCHAR resCode[8];

		// status code を取得
		if(!HttpQueryInfo(hRequest, HTTP_QUERY_STATUS_CODE, resCode, &resLen, 0))
		{
			LastErrorMessageBox(hwnd, _T("Cannot get status code."));
			InternetCloseHandle(hRequest);
			InternetCloseHandle(hConnection);
			InternetCloseHandle(hSession);
			return FALSE;
		}

		// 結果 (URL) を読取る
		DWORD len;
		char  resbuf[1024];
		std::string result;

		// そんなに長いことはないけどまあ一応
		while (InternetReadFile(hRequest, (LPVOID)resbuf, 1024, &len)
			&& len != 0)
		{
			result.append(resbuf, len);
		}

		// 取得結果は NULL terminate されていないので
		result += '\0';

		if( _ttoi(resCode) != 200 ) {
			// upload 失敗 (status error)
			TCHAR errorBuf[200];
			StringCchPrintf(errorBuf, 200, TEXT("Cannot upload the image. Error %s "),resCode);
			std::wstring stemp = std::wstring(result.begin(), result.end());
			StringCchCat(errorBuf, 200, (LPTSTR)stemp.c_str());
			MessageBox(hwnd, errorBuf, szTitle, MB_ICONERROR | MB_OK);
		} else {
			// upload succeeded

			// クリップボードに URL をコピー
			setClipBoardText(result.c_str());
			
			// URL を起動
			execUrl(result.c_str()); 

			bSuccess = TRUE;
		}
	} else {
		// アップロード失敗...
		LastErrorMessageBox(hwnd, _T("Cannot connect to the server."));
	}

	// ハンドルクローズ
	InternetCloseHandle(hRequest);
	InternetCloseHandle(hConnection);
	InternetCloseHandle(hSession);

	return bSuccess;

}
Example #15
0
/*+*************************************************************************
**
** read_saved
**
** Reads all the hosts listed in the INI file.
**
***************************************************************************/
static void
read_saved (void) {
	int i;					/* Index */
	char buff[32];

	for (i = 0; MAX_SAVED; ++i) {		/* Read this many entries */
		wsprintf (buff, INI_HOST "%d", i);
		GetPrivateProfileString(INI_HOSTS, buff, "", hosts[i], 256, GSSAPI_INI);
		if (*hosts[i] == '\0')		/* No more entries??? */
			break;
	}
	for (i = 0; MAX_SAVED; ++i) {		/* Read this many entries */
		wsprintf (buff, INI_SVC "%d", i);
		GetPrivateProfileString(INI_SVCS, buff, "", svcs[i], 256, GSSAPI_INI);
		if (*svcs[i] == '\0')		/* No more entries??? */
			break;
	}
	for (i = 0; MAX_SAVED; ++i) {		/* Read this many entries */
		wsprintf (buff, INI_MSG "%d", i);
		GetPrivateProfileString(INI_MSGS, buff, "", msgs[i], 256, GSSAPI_INI);
		if (*msgs[i] == '\0')		/* No more entries??? */
			break;
	}
	for (i = 0; MAX_SAVED; ++i) {		/* Read this many entries */
		wsprintf (buff, INI_MECH "%d", i);
		GetPrivateProfileString(INI_MECHS, buff, "", mechs[i], 256, GSSAPI_INI);
		if (*mechs[i] == '\0')		/* No more entries??? */
			break;
	}
    GetPrivateProfileString(INI_LAST, INI_LAST_HOST, "", szHost, 256, GSSAPI_INI);
    GetPrivateProfileString(INI_LAST, INI_LAST_PORT, "", buff, 32, GSSAPI_INI);
    if ( buff[0] )
        port = atoi(buff);
    GetPrivateProfileString(INI_LAST, INI_LAST_SVC, "", szService, 256, GSSAPI_INI);
    GetPrivateProfileString(INI_LAST, INI_LAST_MSG, "", szMessage, 256, GSSAPI_INI);
    GetPrivateProfileString(INI_LAST, INI_LAST_MECH, "", szMech, 256, GSSAPI_INI);
    GetPrivateProfileString(INI_LAST, INI_LAST_CCACHE, "", szCCache, 256, GSSAPI_INI);
    GetPrivateProfileString(INI_LAST, INI_LAST_DELEGATE, "", buff, 32, GSSAPI_INI);
    if ( buff[0] )
        delegate = atoi(buff);
    GetPrivateProfileString(INI_LAST, INI_LAST_MUTUAL, "", buff, 32, GSSAPI_INI);
    if ( buff[0] )
        mutual = atoi(buff);
    GetPrivateProfileString(INI_LAST, INI_LAST_REPLAY, "", buff, 32, GSSAPI_INI);
    if ( buff[0] )
        replay = atoi(buff);
    GetPrivateProfileString(INI_LAST, INI_LAST_SEQUENCE, "", buff, 32, GSSAPI_INI);
    if ( buff[0] )
        sequence = atoi(buff);
    GetPrivateProfileString(INI_LAST, INI_LAST_VERBOSE, "", buff, 32, GSSAPI_INI);
    if ( buff[0] )
        verbose = atoi(buff);
    GetPrivateProfileString(INI_LAST, INI_LAST_CCOUNT, "", buff, 32, GSSAPI_INI);
    if ( buff[0] )
        ccount = atoi(buff);
    GetPrivateProfileString(INI_LAST, INI_LAST_MCOUNT, "", buff, 32, GSSAPI_INI);
    if ( buff[0] )
        mcount = atoi(buff);
    GetPrivateProfileString(INI_LAST, INI_LAST_VER1, "", buff, 32, GSSAPI_INI);
    if ( buff[0] )
        gssv1 = atoi(buff);
    GetPrivateProfileString(INI_LAST, INI_LAST_NOAUTH, "", buff, 32, GSSAPI_INI);
    if ( buff[0] )
        noauth = atoi(buff);
    GetPrivateProfileString(INI_LAST, INI_LAST_NOWRAP, "", buff, 32, GSSAPI_INI);
    if ( buff[0] )
        nowrap = atoi(buff);
    GetPrivateProfileString(INI_LAST, INI_LAST_NOCRYPT, "", buff, 32, GSSAPI_INI);
    if ( buff[0] )
        nocrypt = atoi(buff);
    GetPrivateProfileString(INI_LAST, INI_LAST_NOMIC, "", buff, 32, GSSAPI_INI);
    if ( buff[0] )
        nomic = atoi(buff);
}
DWORD
PXEAPI
PxeProviderRecvRequest(
    __in HANDLE hClientRequest,
    __in PVOID pPacket,
    __in ULONG uPacketLen,
    __in PXE_ADDRESS *pLocalAddress,
    __in PXE_ADDRESS *pRemoteAddress,
    __out PXE_BOOT_ACTION *pAction,
    __in PVOID pContext
)
/*++

Routine Description:

    This function is called by WDS PXE when a request is received. All requests
    are processed synchrnously by Filter Provider.

Arguments:

    hClientRequest  -   Handle to received request.
    pPacket         -   Pointer to received data.
    uPacketLen      -   Length, in bytes, of pPacket.
    pLocalAddress   -   Local Address on which this request was received.
    pRemoteAddress  -   Remote Address of client who sent the request.
    pAction         -   [out] Contains the next action that should be taken by
                        WDS PXE.
    pContext        -   Context which was passed to WDSPXE when callback was 
                        registered.

Return Value:

    ERROR_SUCCESS on success. On failure appropriate Win32 Error Code is 
    returned.

--*/
{
    DWORD dwError = ERROR_SUCCESS;
    WCHAR wszMacAddress[MAX_MAC_ADDR_STRING_LEN];
    WCHAR wszValue[8] = { 0 };
    ULONG uDevicePolicy = VAL_DEVICE_POLICY_DENY;
    BOOL bDeviceFound = FALSE;
    
    //
    // Convert client MAC address to string.
    //
    dwError = GetClientMacAddress(pPacket, 
                                  wszMacAddress);
    W32_CLEANUP_ON_FAILURE(dwError, Cleanup);

    //
    // Check if the MAC address exists.
    //
    if (GetPrivateProfileString(DEVICES_SECTION,
                                wszMacAddress,
                                NULL,
                                wszValue,
                                NUMELEM(wszValue),
                                g_wszConfigurationFile))
    {
        uDevicePolicy = _wtoi(wszValue);

        switch(uDevicePolicy)
        {
        case VAL_DEVICE_POLICY_ALLOW:
        case VAL_DEVICE_POLICY_DENY:
            break;

        default:
            uDevicePolicy = VAL_DEVICE_POLICY_DENY;
            break;
        }

        bDeviceFound = TRUE;
    }

    //
    // If device was found, then use Per-Device policy to decide.
    //
    if (bDeviceFound)
    {
        if (uDevicePolicy == VAL_DEVICE_POLICY_ALLOW)
            *pAction = PXE_BA_REJECTED;
        else
            *pAction = PXE_BA_IGNORE;
    }
    //
    // Device was not found, so use global settings to decide.
    //
    else
    {
        if (g_uFilterPolicy == VAL_FILTER_POLICY_ALLOW)
            *pAction = PXE_BA_REJECTED;
        else
            *pAction = PXE_BA_IGNORE;
    }
    
Cleanup:
    return dwError;
}
Example #17
0
//this is the state machine which controls 
//	what commands to send, 
//	when to send them, and
//	what to expect in return.
//It receives a message for each message returned from an instrument
//as well as a "timer" message on intervals selected in "MIC:Configuration"
LRESULT CJSRInst::OnReceive(WPARAM WParam, LPARAM LParam)
{
	//wparam is the type of message and lparam is the checksum good or bad
	//this is true for all messages EXCEPT the battery backed value message
	//in this one case lparam contains the number of bytes in bbm.
	//<<QA>> PJM: JSR does not have BBM.  Not sure if the above comment is
	//<<QA>> otherwise correct.

	CString temp;
	//if we couldn't register this instrument 
	//or if disk is full so we are blocking write
	//then lock it up in state 9900 -- don't send anything
	if (!m_bGoodRegister || m_bBlockWrite)
		m_dCurrent_State = 9900;

	if (WParam == TRIGGER_CAMERA_REQUEST)
	{
		if (m_dParallelPortPin && !m_bCameraBlocked)
		{
			//if (current time < suppression end time) then return
			COleDateTime now = COleDateTime::GetCurrentTime();
			if (now < m_pSuppressUntil) 
			{
				m_pSummaryPage->GetDlgItemText(IDC_JSRSUMMARY_CAMERA_TRIG,temp);
				temp += " Suppressed";
				m_pSummaryPage->SetDlgItemText(IDC_JSRSUMMARY_CAMERA_TRIG,temp);
				return 0; 
			}
			//set timer to post TRIGGER_CAMERA_START at now + holdoffspan
			SetTimer(TIMER_CAMERA_START,(unsigned)m_pCameraHoldOff.GetTotalSeconds()*1000+1,NULL);
			//set suppression end time at now + m_pCameraSuppress
			m_pSuppressUntil = now + m_pCameraSuppress;
		}
		else
		{
			m_pSummaryPage->GetDlgItemText(IDC_JSRSUMMARY_CAMERA_TRIG,temp);
			temp += " Deactivated";
			m_pSummaryPage->SetDlgItemText(IDC_JSRSUMMARY_CAMERA_TRIG,temp);
		}
		return 0;
	}

	else if (WParam == TRIGGER_CAMERA_START_TEST)
	{
		//set parallel port high
		if (m_dParallelPortPin  && !m_bCameraBlocked)
		{
 			//set the pin on
			m_cParallelPort.SetPin(m_dParallelPortPin);

			//tell the world
			//m_pSummaryPage->GetDlgItemText(IDC_JSRSUMMARY_CAMERA_TRIG,temp);

			COleDateTime now = COleDateTime::GetCurrentTime();
			temp = now.Format("%Y.%m.%d %H:%M:%S Test Do");                         
			m_pSummaryPage->SetDlgItemText(IDC_JSRSUMMARY_CAMERA_TRIG,temp);

			//set timer TIMER_CAMERA_END
			SetTimer(TIMER_CAMERA_END,600,NULL);
			m_pPropertySheet->WriteToFile(TO_CEV, TYPE_COMP, NULL,"53035 Camera Triggered Test\n");
		}
		return 0;
	}


	else if (WParam == TRIGGER_CAMERA_START)
	{
		//set parallel port high
		if (m_dParallelPortPin && !m_bCameraBlocked)
		{
			try
			{
				//set the pin on
				m_cParallelPort.SetPin(m_dParallelPortPin);
			}
			catch(...)
			{
				return 0;
			}

			//tell the world
			m_pSummaryPage->GetDlgItemText(IDC_JSRSUMMARY_CAMERA_TRIG,temp);
			temp += " Do";
			m_pSummaryPage->SetDlgItemText(IDC_JSRSUMMARY_CAMERA_TRIG,temp);

			//set timer TIMER_CAMERA_END
			SetTimer(TIMER_CAMERA_END,600,NULL);
			m_pPropertySheet->WriteToFile(TO_CEV, TYPE_COMP, NULL,"53030 Camera Triggered\n");
		}
		return 0;
	}

	else if (WParam == TRIGGER_CAMERA_END)
	{
//		TRACE("CJSRInst::OnReceive(WParam = TRIGGER_CAMERA_END)\n");

		//set parallel port low (don't forget to initialize it low)
		if (m_dParallelPortPin && !m_bCameraBlocked)
		{
			m_cParallelPort.UnSetPin(m_dParallelPortPin);
			m_pSummaryPage->GetDlgItemText(IDC_JSRSUMMARY_CAMERA_TRIG,temp);
			temp += "ne";
			m_pSummaryPage->SetDlgItemText(IDC_JSRSUMMARY_CAMERA_TRIG,temp);
		}

		return 0;
	}

	else if (WParam == TIMER_TICK)
	{
		//bump time increments to next inquire
		m_dTickToInquire++;
		//bump time from last command
		m_dTick_Count++;
		if ((m_dRetransmit > m_dCommFail) &&
			(m_dCurrent_State != 9010) &&
			(m_dCurrent_State != 9500))
		{		
				m_dRetransmit = 0;
				m_dTick_Count =	0;
				m_dCurrent_State = 9000; //hard fail
		}
	}

	if (m_dCurrent_State < 9000)
		m_bInShutDown = false;
	else
		m_bInShutDown = true;

	if (m_dCurrent_State >= 1100)
		m_bInStartUp = false;
	else
		m_bInStartUp = true;
	//this is the virtual instrument state machine
	switch (m_dCurrent_State)
	{
	//start by sending ^ to force mode to computer
	case 1000:
		if (WParam == RESETUP)
		{
			char resetstring[64];
			char temp[16];
			GetPrivateProfileString(m_pName,"COUNTTIMEUNIT","10",temp,sizeof(temp),m_szIniFile);
			while (strlen(temp) < 2)
			{
				temp[2] = temp[1];
				temp[1] = temp[0];
				temp[0] = '0';
			}
			strcpy(resetstring,"U");
			strcat(resetstring,temp);
			GetPrivateProfileString(m_pName,"COUNTTIMEEXP","0",temp,sizeof(temp),m_szIniFile);
			temp[1] = NULL;
			strcat(resetstring,"E");
			strcat(resetstring,temp);
			GetPrivateProfileString(m_pName,"PREDELAY","1",temp,sizeof(temp),m_szIniFile);
			temp[1] = NULL;
			strcat(resetstring,"P");
			strcat(resetstring,temp);
			GetPrivateProfileString(m_pName,"GATEWIDTH","100",temp,sizeof(temp),m_szIniFile);
			while (strlen(temp) < 3)
			{
				temp[2] = temp[1];
				temp[1] = temp[0];
				temp[0] = '0';
			}
			temp[3] = NULL;
			strcat(resetstring,"G");
			strcat(resetstring,temp);
			GetPrivateProfileString(m_pName,"HIGHV","1800",temp,sizeof(temp),m_szIniFile);
			while (strlen(temp) < 4)
			{
				temp[3] = temp[2];
				temp[2] = temp[1];
				temp[1] = temp[0];
				temp[0] = '0';
			}
			temp[4] = NULL;
			strcat(resetstring,"V");
			strcat(resetstring,temp);
			strcat(resetstring,"J");
#ifdef _DEBUG
			//Indicate that new hardware commands are being
			//sent to the JSR
			Beep(200,300);	//SCR00114
#endif
			COM_Transmit(ISZSTRING,resetstring,m_iNode);
			m_pPropertySheet->UpdateSummary(resetstring);
			strcat(resetstring,"\n");

			char cBuff[1024];
			strcpy(cBuff,"53040 JSR Parameters reset: ");
			strcat(cBuff,resetstring);
			m_pPropertySheet->WriteToFile(TO_PFM, TYPE_COMP, NULL, cBuff);

			//m_pPropertySheet->WriteToFile(TO_PFM | TO_CEV, TYPE_COMP, NULL,"304 JSR Parameters reset\n");
			//m_pPropertySheet->WriteToFile(TO_PFM | TO_CEV, TYPE_COMP, NULL,resetstring);

			if (m_bDoDump)
			{
					m_pPropertySheet->WriteToFile(TO_DMP, TYPE_DUMP, NULL, cBuff);
					//m_pPropertySheet->WriteToFile(TO_DMP, TYPE_DUMP, NULL, "304 JSR Parameters reset\n");
					//m_pPropertySheet->WriteToFile(TO_DMP, TYPE_DUMP, NULL, resetstring);
			}
			break;
		}

		if (m_bPause) 
		{
			m_bIsPaused = true;
			m_pButton->put_FaceColor(COLOR_PAUSE);
			m_pPropertySheet->m_pCloseButton->SetFaceColor(COLOR_PAUSE);
			break;
		}

		if (WParam == TIMER_TICK)
		{
			m_pButton->put_FaceColor(COLOR_WAIT);
			m_pPropertySheet->m_pCloseButton->SetFaceColor(COLOR_WAIT);
			COM_Transmit(ISZSTRING,"HX",m_iNode);
			m_pPropertySheet->UpdateSummary("HX - In Computer Mode?");
			if (m_bDoDump)
				m_pPropertySheet->WriteToFile(TO_DMP, TYPE_DUMP, NULL, "53050 HX - In Computer Mode? (1000)\n");
			m_dCurrent_State = 1010;
		}


		break;

	//wait for response 
	case 1010:
		if (m_bPause) 
		{
			m_bIsPaused = true;
			m_pButton->put_FaceColor(COLOR_PAUSE);
			m_pPropertySheet->m_pCloseButton->SetFaceColor(COLOR_PAUSE);
			break;
		}
		//got a "?0000000" back 
		if (WParam == JSR_STATUS_RECORD)
		{
			m_dTickToInquire = 0;
			m_dTick_Count = 0;
			m_dRetransmit = 0;
//			m_bInHardFail = false;
			m_dCurrent_State = 1100;//good response so start it up
		}

		//if we didn't get anything back 
		//in the alloted time so assume Front Panel Mode
		if (m_dTick_Count <= m_dTimeOut)
			break;

		m_dCurrent_State = 1020;//^X transmit
		//fall through

	case 1020:
		if (m_bPause) 
		{
			m_dCurrent_State = 1000;
			m_bIsPaused = true;
			m_pButton->put_FaceColor(COLOR_PAUSE);
			m_pPropertySheet->m_pCloseButton->SetFaceColor(COLOR_PAUSE);
			break;
		}
		if (WParam == TIMER_TICK)
		{
//			m_pButton->SetFlagChar(FLAG_CHAR,true);
//			m_pButton->put_FaceColor(COLOR_WAIT);
//			m_pPropertySheet->m_pCloseButton->SetFaceColor(COLOR_WAIT);
//			m_dTickToInquire = 0;
//			m_dTickToStatus  = 0;
			m_dTick_Count = 0;
			COM_Transmit(ISZSTRING,"\x08\x18",m_iNode);//^H^X
			m_pPropertySheet->UpdateSummary("^H^X - Terminal Mode?");
			if (m_bDoDump)
				m_pPropertySheet->WriteToFile(TO_DMP, TYPE_DUMP, NULL, "53060 ^H^X - Terminal Mode? (1020)\n");
			m_dCurrent_State = 1030;
		}
		break;

	case 1030:
		if (m_bPause) 
		{
			m_dCurrent_State = 1000;
			m_bIsPaused = true;
			m_pButton->put_FaceColor(COLOR_PAUSE);
			m_pPropertySheet->m_pCloseButton->SetFaceColor(COLOR_PAUSE);
			break;
		}

		//got a "10000000" back 
		if (WParam == JSR_STATUS_RECORD)
		{
			m_dTickToInquire = 0;
			m_dTick_Count = 0;
			m_dRetransmit = 0;
//			m_bInHardFail = false;
			m_dCurrent_State = 1040;//good response so enter computer mode
		}

		//if we didn't get anything back 
		//in the alloted time so assume Front Panel Mode
		if (m_dTick_Count <= m_dTimeOut)
			break;

		//never got anything so attempt reset
		m_dCurrent_State = 1140;//reset JSR with escape character
//		break;
		//fall through

	case 1040:
		if (m_bPause) 
		{
			m_dCurrent_State = 1000;
			m_bIsPaused = true;
			m_pButton->put_FaceColor(COLOR_PAUSE);
			m_pPropertySheet->m_pCloseButton->SetFaceColor(COLOR_PAUSE);
			break;
		}
		if (WParam == TIMER_TICK)
		{
			m_dTick_Count = 0;
			COM_Transmit(ISZSTRING,"^",m_iNode);//^
			m_pPropertySheet->UpdateSummary("^ - In Computer Mode?");
			if (m_bDoDump)
				m_pPropertySheet->WriteToFile(TO_DMP, TYPE_DUMP, NULL, "53070 ^ - In Computer Mode? (1040)\n");
			m_dCurrent_State = 1050;
		}
		break;

	case 1050:
		if (m_bPause) 
		{
			m_dCurrent_State = 1000;
			m_bIsPaused = true;
			m_pButton->put_FaceColor(COLOR_PAUSE);
			m_pPropertySheet->m_pCloseButton->SetFaceColor(COLOR_PAUSE);
			break;
		}
		//got the expected "V 6.1 17-NOV-95" record back
		//we are in monitor mode
		if (WParam == JSR_VERSION_RECORD)
		{
			m_dRetransmit = 0;
//			m_bInHardFail = false;
			break;
		}

		//got a "10000000" back 
		if (WParam == JSR_STATUS_RECORD)
		{
			m_dRetransmit = 0;
//			m_bInHardFail = false;
			m_dCurrent_State = 1100;//good response so start it up
			break;
		}

	case 1060:
		if (m_bPause) 
		{
			m_dCurrent_State = 1000;
			m_bIsPaused = true;
			m_pButton->put_FaceColor(COLOR_PAUSE);
			m_pPropertySheet->m_pCloseButton->SetFaceColor(COLOR_PAUSE);
			break;
		}

		if (WParam == TIMER_TICK)
		{
			m_pButton->SetErrorIcon_Flag();
			m_pButton->put_FaceColor(COLOR_WAIT);
			m_pPropertySheet->m_pCloseButton->SetFaceColor(COLOR_WAIT);
//			m_dTickToInquire = 0;
//			m_dTickToStatus  = 0;
			m_dTick_Count = 0;
			COM_Transmit(ISZSTRING,"\x1b",m_iNode);
			m_pPropertySheet->UpdateSummary("<esc> - reset JSR");
			if (m_bDoDump)
				m_pPropertySheet->WriteToFile(TO_DMP, TYPE_DUMP, NULL, "53080 <esc> - reset JSR (1060)\n");
			m_dRetransmit++;
			if (m_bInHardFail)
				m_dCurrent_State = 9000;
			else
			{
				m_bInHardFail = true;
				m_dCurrent_State = 1000;
			}
		}
		break;

	case 1100:
		if (m_bPause) 
		{
			m_dCurrent_State = 1000;
			m_bIsPaused = true;
			m_pButton->put_FaceColor(COLOR_PAUSE);
			m_pPropertySheet->m_pCloseButton->SetFaceColor(COLOR_PAUSE);
			break;
		}
		//we are in a dumplast sequence
		m_bInDumpLast = false;
		//send the command
		COM_Transmit(ISZSTRING,"J",m_iNode);
		m_pPropertySheet->UpdateSummary("J");
		if (m_bDoDump)
				m_pPropertySheet->WriteToFile(TO_DMP, TYPE_DUMP, NULL, "53090 J - Get setup values (1100)\n");
		//incr the number of times command has been sent
		m_dRetransmit++;
		//start the tick count at 0 so we can detect time out
		m_dTick_Count = 0;
		//next state will wait for a good response
		m_dCurrent_State = 1110;
		break;

	case 1110:
		if (m_dTick_Count > m_dTimeOut)
		{
			m_dTick_Count = 0;
			m_dCurrent_State = 1000;
			m_pPropertySheet->WriteToFile(TO_PFM, TYPE_COMP, NULL,"53100 JSR Timeout on receive SETUP response\n");
		} 
		//beak out and wait for correct response
		if (WParam != JSR_SETUP_RECORD)  
			break;
		if (LParam)
			m_dInquireInt = (int)((float)LParam/((float)m_dCycleInt/1000.0))-3;
		else
		{
			double temp = (double)m_dCountTimeUnit * pow(10,(double)(m_dCountTimeExp-1));
			m_dInquireInt = (int)(temp/((double)m_dCycleInt/1000.0))-3;
			//the -3 is to give ourself about 1 second
		}
		m_dTick_Count = 0;
		m_dCurrent_State = 1120;
		m_dRetransmit = 0;
//		break; //fall through

	case 1120:
		if (m_bPause) 
		{
			m_dCurrent_State = 1000;
			m_bIsPaused = true;
			m_pButton->put_FaceColor(COLOR_PAUSE);
			m_pPropertySheet->m_pCloseButton->SetFaceColor(COLOR_PAUSE);
			break;
		}
//		//we are in a dumplast sequence
//		m_bInDumpLast = false;
		//send the command
		COM_Transmit(ISZSTRING,"Y",m_iNode);
		m_pPropertySheet->UpdateSummary("Y");
		if (m_bDoDump)
				m_pPropertySheet->WriteToFile(TO_DMP, TYPE_DUMP, NULL, "53110 Y - Get actual HV (1120)\n");
		//incr the number of times command has been sent
		m_dRetransmit++;
		//start the tick count at 0 so we can detect time out
		m_dTick_Count = 0;
		//next state will wait for a good response
		m_dCurrent_State = 1130;
		break;

	case 1130:
		if (m_dTick_Count > (m_dTimeOut+3))
		{
			m_dTick_Count = 0;
			m_dCurrent_State = 1100;
			m_pPropertySheet->UpdateSummary("JSR Timeout on receive HV");
			m_pPropertySheet->WriteToFile(TO_PFM, TYPE_COMP, NULL,"53120 JSR Timeout on receive actual HV response\n");
		} 
		//beak out and wait for correct response
		if (WParam != JSR_HV_RECORD)  
			break;

		m_pButton->put_FaceColor((m_bPause)?COLOR_PAUSE:COLOR_OK);
		m_pPropertySheet->m_pCloseButton->SetFaceColor((m_bPause)?COLOR_PAUSE:COLOR_OK);
		m_dCurrent_State = 1140;

//		break; //fall through
	case 1140:
		if (m_bPause) 
		{
			m_dCurrent_State = 1000;
			m_bIsPaused = true;
			m_pButton->put_FaceColor(COLOR_PAUSE);
			m_pPropertySheet->m_pCloseButton->SetFaceColor(COLOR_PAUSE);
			break;
		}
		//we are in a dumplast sequence
		m_bInDumpLast = false;
		//send the command
		COM_Transmit(ISZSTRING,"Z&",m_iNode);
		m_pPropertySheet->m_LastStart = COleDateTime::GetCurrentTime();
		m_pPropertySheet->UpdateSummary("Z&&");
		if (m_bDoDump)
			m_pPropertySheet->WriteToFile(TO_DMP, TYPE_DUMP, NULL, "53130 Z& - Zero and Auto (1140)\n");
		m_dTickToInquire = 0;
		m_dRetransmit = 0;
		m_dTick_Count = 0;
		//next state will wait for a good response
//		m_dCurrent_State = 2000;
		//fall through
		m_dCurrent_State = 1150;
		break;

	case 1150://wait a short time
//		if (m_dTick_Count >= (1000.0/(float)m_dCycleInt))
		if (m_dTick_Count >= (600.0/(float)m_dCycleInt))//dgp
		{
			m_dTick_Count = 0;
			m_dCurrent_State = 1160;
		}
		break;

	case 1160:
		//send the read status command
		COM_Transmit(ISZSTRING,"X",m_iNode);
		m_pPropertySheet->UpdateSummary("X");
		if (m_bDoDump)
				m_pPropertySheet->WriteToFile(TO_DMP, TYPE_DUMP, NULL, "53140 X - get status (3400)\n");
		//incr the number of times command has been sent
		m_dRetransmit++;
		//start the tick count at 0 so we can detect time out
		m_dTick_Count = 0;
		//next state will wait for a good response
		m_dCurrent_State = 1170;
		break;

	case 1170:
		if (m_dTick_Count > m_dTimeOut)
		{
			m_dTick_Count = 0;
			m_dCurrent_State = 1000;
			m_pPropertySheet->UpdateSummary("Timeout on receive initial status response");
			m_pPropertySheet->WriteToFile(TO_PFM, TYPE_COMP, NULL,"53150 JSR Timeout on receive initial status response\n");
		} 

		//break out and wait for correct response
		if (WParam == JSR_STATUS_RECORD)  
		{
			m_dRetransmit = 0;
			m_dTick_Count = 0;
			if (LParam == 1)
				m_dCurrent_State = 1000;//total reset, couldn't start jsr
			else
				m_dCurrent_State = 2000;//looks good
		}
		break;
		

	//state 2000 is the "normal" resting state
	case 2000:

		if (m_bPause) 
		{
			m_dCurrent_State = 1000;
			m_bIsPaused = true;
			m_pButton->put_FaceColor(COLOR_PAUSE);
			m_pPropertySheet->m_pCloseButton->SetFaceColor(COLOR_PAUSE);
			break;
		}

		//tell the buttons we are now waiting for expected data record
		if  (
			(WParam == TIMER_TICK)	&&
			(m_dTickToInquire >= m_dInquireInt) 
			)
		{
			m_pButton->put_FaceColor(COLOR_WAIT);
			m_pPropertySheet->m_pCloseButton->SetFaceColor(COLOR_WAIT);
			COM_Transmit(ISZSTRING,"X",m_iNode);
			m_dTransmitXCount = 0;
			m_dRetransmit++;
			m_dTick_Count = 0;
			m_dCurrent_State = 2100;
			break;
		}
		break;

	case 2100:
		if (m_bPause) 
		{
			m_dCurrent_State = 1000;
			m_bIsPaused = true;
			m_pButton->put_FaceColor(COLOR_PAUSE);
			m_pPropertySheet->m_pCloseButton->SetFaceColor(COLOR_PAUSE);
			break;
		}

		//if enough time has passed that we may need to reset instrument
//		if (m_dTickToInquire >= (m_dInquireInt + 8))  
		if ((m_dTick_Count >= m_dTimeOut) && (WParam != JSR_STATUS_RECORD))
		{
			char cBuff[1024];
			strcpy(cBuff,"53160 Late Response (2100)\n");

			m_pPropertySheet->UpdateSummary("Late Response (2100)");
			m_pPropertySheet->WriteToFile(TO_PFM | TO_CEV, TYPE_COMP, NULL, cBuff);
		//	m_pPropertySheet->WriteToFile(TO_PFM | TO_CEV, TYPE_COMP, NULL,"Late Response - Resetting JSR (2100)\n");

			if (m_bDoDump)
			//	m_pPropertySheet->WriteToFile(TO_DMP, TYPE_DUMP, NULL, "Late Response - Resetting JSR (2100)\n");
				m_pPropertySheet->WriteToFile(TO_DMP, TYPE_DUMP, NULL, cBuff);


			m_dCurrent_State = 2000; 
			m_dTick_Count = 0;
			break;
		} 

		if (WParam == JSR_STATUS_RECORD)
		{
			m_dRetransmit = 0;
			if (LParam == 1)
			{
				m_dCurrent_State=3000;
				//fall through -- don't break
				if ((m_bDoDump)||(m_pSummaryPage->m_bDebug))
					GetLocalTime(&m_Then);
			}
			else
			{
				COM_Transmit(ISZSTRING,"X",m_iNode);
				m_dTickToInquire = 0;
				m_dTransmitXCount++;
				m_dRetransmit++;
				m_dTick_Count = 0;
				m_dCurrent_State = 2100;
				break;
			}
		}
		else
			break;

#define CR
#undef CR
	case 3000:	//send read
		//send the command
#ifdef CR
		COM_Transmit(ISZSTRING,"CR",m_iNode);//dgp
		m_pPropertySheet->UpdateSummary("CR");//dgp
		if (m_bDoDump)
			m_pPropertySheet->WriteToFile(TO_DMP, TYPE_DUMP, NULL, "53170 CR - Get Aux value (3000)\n");
#else
		COM_Transmit(ISZSTRING,"C",m_iNode);//dgp
		m_pPropertySheet->UpdateSummary("C");//dgp
		if (m_bDoDump)
			m_pPropertySheet->WriteToFile(TO_DMP, TYPE_DUMP, NULL, "53170 C - Get Aux value (3000)\n");
#endif
		//incr the number of times command has been sent
		m_dRetransmit++;
		//start the tick count at 0 so we can detect time out
		m_dTick_Count = 0;
		//reset retransmit
		m_dRetransmit++;
		//next state will wait for a good response
		m_dCurrent_State = 3100;
		break;

	case 3100:
		//wait for response
		if (m_dTick_Count > m_dTimeOut)
		{
			m_dTick_Count = 0;
			m_dCurrent_State = 1100;
			m_pPropertySheet->WriteToFile(TO_PFM, TYPE_COMP, NULL,"53180 JSR Timeout on receive AUX data response\n");

			if (m_bDoDump)
				m_pPropertySheet->WriteToFile(TO_DMP, TYPE_DUMP, NULL, "53180 Timeout on receive AUX data response (3100)\n");

		} 
		//break out and wait for correct response
		if (WParam != JSR_AUX_RECORD)
			break;

		m_pButton->put_FaceColor((m_bPause)?COLOR_PAUSE:COLOR_OK);
		m_pPropertySheet->m_pCloseButton->SetFaceColor((m_bPause)?COLOR_PAUSE:COLOR_OK);
		m_dRetransmit = 0;
#ifdef CR
		m_dCurrent_State = 3300;//dgp
		m_dTick_Count = 0;//dgp
		break;//dgp
#endif
//		break;
		//fall through to read aux data

	case 3200:	//send read
		//send the command
		COM_Transmit(ISZSTRING,"R",m_iNode);
		m_pPropertySheet->UpdateSummary("R");
		if (m_bDoDump)
			m_pPropertySheet->WriteToFile(TO_DMP, TYPE_DUMP, NULL, "53190 R - Get values (3200)\n");
		//incr the number of times command has been sent
		m_dRetransmit++;
		//start the tick count at 0 so we can detect time out
		m_dTick_Count = 0;
		//next state will wait for a good response
		m_dCurrent_State = 3300;
		break;

	case 3300:
		if (m_dTick_Count > (m_dTimeOut + 1))
		{
			m_dTick_Count = 0;
			m_dCurrent_State = 2100;
			m_pPropertySheet->UpdateSummary("Timeout on receive DATA response");
			m_pPropertySheet->WriteToFile(TO_PFM, TYPE_COMP, NULL,"53200 JSR Timeout on receive DATA response\n");
		} 
		//break out and wait for correct response
		if (WParam != JSR_READ_RECORD)  
			break;

		m_pButton->put_FaceColor((m_bPause)?COLOR_PAUSE:COLOR_OK);
		m_pPropertySheet->m_pCloseButton->SetFaceColor((m_bPause)?COLOR_PAUSE:COLOR_OK);
		//start another measurement
		COM_Transmit(ISZSTRING,"Z&",m_iNode);
		m_pPropertySheet->m_LastStart = COleDateTime::GetCurrentTime();
		m_dTickToInquire = 0;
		m_pPropertySheet->UpdateSummary("Z&&");
		if (m_bDoDump)
			m_pPropertySheet->WriteToFile(TO_DMP, TYPE_DUMP, NULL, "53210 Z& - Zero and Auto (3300)\n");

		m_dRetransmit = 0;
		m_dTick_Count = 0;
		//get rest of data
		m_dCurrent_State = 3401;
		break;

	case 3401://wait a reasonable time or not
//		if (m_dTick_Count >= (1000.0/(float)m_dCycleInt))
//		if (m_dTick_Count > (100.0/(float)m_dCycleInt))
		{
			m_dTick_Count = 0;
			m_dCurrent_State = 3400;
			m_dRetransmit = 0;
		}
//		break;

	case 3400:
		//send the read status command
		COM_Transmit(ISZSTRING,"X",m_iNode);
		m_pPropertySheet->UpdateSummary("X");
		if (m_bDoDump)
				m_pPropertySheet->WriteToFile(TO_DMP, TYPE_DUMP, NULL, "53220 X - get status (3400)\n");
//		//incr the number of times command has been sent
//		m_dRetransmit++;
		//use retrans to count bad responses
		m_dRetransmit = 0;
		//start the tick count at 0 so we can detect time out
		m_dTick_Count = 0;
		//next state will wait for a good response
		m_dCurrent_State = 3410;
		//get the system time
		GetSystemTime(&m_sStartTime);
		break;

	case 3410:

		//if we don't get a response in a reasonable time try to reset
		if (m_dTick_Count > m_dTimeOut)
		{
			m_dTick_Count = 0;
			m_dRetransmit = 0;
			m_dCurrent_State = 1000;
			m_pPropertySheet->UpdateSummary("Timeout on receive status response");
			m_pPropertySheet->WriteToFile(TO_PFM, TYPE_COMP, NULL,"53230 JSR Timeout on receive status response\n");
		} 

		//regardless of time out if we have a bunch of bad responses then reset
		if (WParam == JSR_UNKNOWN_RECORD)
		{
			//user retransmit to count error responses
			m_dRetransmit++;
			if (m_dRetransmit > 4)
			{
				m_dTick_Count = 0;
				m_dRetransmit = 0;
				m_dCurrent_State = 1000;
				m_pPropertySheet->UpdateSummary("Too many bad status responses");
				m_pPropertySheet->WriteToFile(TO_PFM, TYPE_COMP, NULL,"53240 JSR Too many bad status response\n");
			}
			else
				//immediately ask again if started count time
				COM_Transmit(ISZSTRING,"X",m_iNode);
		}
		//else we must have a status record (WParam == JSR_STATUS_RECORD)  
		else if (WParam == JSR_STATUS_RECORD)
		{
			char szTemp[32];
			m_dRetransmit = 0;
			m_dTick_Count = 0;
			if (LParam == 1)
			{
				//not started yet

				//next state will wait for a good response
				m_dCurrent_State = 3410;

				//calculate the time since first X command
				SYSTEMTIME sStartTime;
				GetSystemTime(&sStartTime);
				int iDiff = CalculateDiff(&sStartTime,&m_sStartTime);

				//don't wait any longer than 600 msec
				if (iDiff > 700)
				{
					m_dCurrent_State = 1000;//total reset, couldn't start jsr
					//don't immediately go to slow reset state
					m_dRetransmit = 0;
					m_pPropertySheet->UpdateSummary("Too much time to restart");
					m_pPropertySheet->WriteToFile(TO_PFM, TYPE_COMP, NULL,"53250 JSR Too much time to restart\n");
				}
				else
				{
					//immediately ask again if started count time
					COM_Transmit(ISZSTRING,"X",m_iNode);
					//incr the number of times command has been sent
				}
		
			}
			else
			{
				m_dRetransmit = 0;
				m_dCurrent_State = 3500;//looks good

				if ((m_bDoDump)||(m_pSummaryPage->m_bDebug))
				{
					SYSTEMTIME Now;
					GetLocalTime(&Now);
					sprintf(szTemp,"53260 Dead(msec): %d",CalculateDiff(&Now,&m_Then));

					SYSTEMTIME sStartTime;
					GetSystemTime(&sStartTime);
					int iDiff = CalculateDiff(&sStartTime,&m_sStartTime);


					//put in debug window if required
					if (m_pSummaryPage->m_bDebug)
						m_pSummaryPage->SetDlgItemText(IDC_STATIC_NOTE3,szTemp);
					//put in dump file if required
					if (m_bDoDump)
					{
						strcat(szTemp,"\n");
						m_pPropertySheet->WriteToFile(TO_DMP,TYPE_DUMP,NULL,szTemp);
					}
					sprintf(szTemp,"53270 Time: %d",iDiff);
					//put in window if required
					if (m_pSummaryPage->m_bDebug)
						m_pPropertySheet->UpdateSummary(szTemp);

					if (m_bDoDump)
					{
						strcat(szTemp,"\n");
						m_pPropertySheet->WriteToFile(TO_DMP,TYPE_DUMP,NULL,szTemp);
					}
				}
			}
		}

		break;

	case 3500:
		//send the command
		COM_Transmit(ISZSTRING,"J",m_iNode);
		m_pPropertySheet->UpdateSummary("J");
		if (m_bDoDump)
			m_pPropertySheet->WriteToFile(TO_DMP, TYPE_DUMP, NULL, "53280 J - Get Setup (3500)\n");
		//incr the number of times command has been sent
		m_dRetransmit++;
		//start the tick count at 0 so we can detect time out
		m_dTick_Count = 0;
		//next state will wait for a good response
		m_dCurrent_State = 3510;
		break;

	case 3510:
		if (m_dTick_Count > m_dTimeOut)
		{
			m_dTick_Count = 0;
			m_dCurrent_State = 1100;
			m_pPropertySheet->WriteToFile(TO_PFM, TYPE_COMP, NULL,"53290 JSR Timeout on receive SETUP response\n");
		} 
		//break out and wait for correct response
		if (WParam != JSR_SETUP_RECORD)  
			break;

		//adjust for how busy the system is
		if (m_dTransmitXCount == 0)
			m_dInquireIntAdjust -= 10;
		else if (m_dTransmitXCount == 1)
			m_dInquireIntAdjust -= 2; 
		else if (m_dTransmitXCount < 5)
			m_dInquireIntAdjust--;
		else if ((m_dTransmitXCount > 30)&&(m_dTransmitXCount < 80))
			m_dInquireIntAdjust++;
		else if (m_dTransmitXCount >= 80)
			m_dInquireIntAdjust += (m_dTransmitXCount/30);

		if (LParam)
			m_dInquireInt = (int)((float)LParam/((float)m_dCycleInt/1000.0))-3;
		else
		{
			double temp = (double)m_dCountTimeUnit * pow(10,double(m_dCountTimeExp-1));
			m_dInquireInt = (int)(temp/((double)m_dCycleInt/1000.0))-3;
		}

		m_dInquireInt += m_dInquireIntAdjust;

		if (m_pSummaryPage->m_bDebug)
		{
			CString temp;
			temp.Format("Xs:%d Wait:%d",m_dTransmitXCount,m_dInquireInt);
			m_pSummaryPage->SetDlgItemText(IDC_STATIC_NOTE1,temp);
		}

		//reset retransmit
		m_dRetransmit = 0;
		//next logical state
		m_dCurrent_State = 3600;
		//fall through to next transmit

	case 3600:
		//send the command
		COM_Transmit(ISZSTRING,"Y",m_iNode);
		m_pPropertySheet->UpdateSummary("Y");
		if (m_bDoDump)
				m_pPropertySheet->WriteToFile(TO_DMP, TYPE_DUMP, NULL, "53300 Y - Get HV\n");
		//incr the number of times command has been sent
		m_dRetransmit++;
		//start the tick count at 0 so we can detect time out
		m_dTick_Count = 0;
		//next state will wait for a good response
		m_dCurrent_State = 3610;
		break;

	case 3610:
		if (m_dTick_Count > m_dTimeOut)
		{
			m_dTick_Count = 0;
			m_dCurrent_State = 1100;
			m_pPropertySheet->UpdateSummary("Timeout on receive HV");
			m_pPropertySheet->WriteToFile(TO_PFM, TYPE_COMP, NULL,"53310 JSR Timeout on receive HV response (3610)\n");
		} 

		//break out and wait for correct response
		if (WParam != JSR_HV_RECORD)  
			break;

		//reset retransmit
		m_dRetransmit = 0;
		//not waiting for a respons
		m_dTick_Count = 0;
		//tell the world we are ok
		m_pButton->put_FaceColor((m_bPause)?COLOR_PAUSE:COLOR_OK);
		m_pPropertySheet->m_pCloseButton->SetFaceColor((m_bPause)?COLOR_PAUSE:COLOR_OK,true);
		//wait for timeout on "inquire"
		m_dCurrent_State = 2000;
		break;

		//long hard fail recovery
	case 9000:							//	900sec/15min
		if ((m_dTick_Count * m_dCycleInt) > m_dSlowReset)//wait 15 minutes before we retry
		{
			m_dTick_Count = 0;
//			m_dHardFailCount = 0;
			m_pButton->SetErrorIcon_Flag();
			m_dCurrent_State = 1000;
		}

		if ((m_dTick_Count % 10) == 0)
		{
			//m_pButton->SetFlagChar(SKULL_CHAR,false);
			m_pButton->SetErrorIcon_Skull();
			m_pButton->put_FaceColor(COLOR_ERROR);
			m_pPropertySheet->m_pCloseButton->SetFaceColor(COLOR_ERROR);
			FlagComm(1,true);			
		}
		break;

	case 9800:
		m_dCurrent_State = 9810;
		PauseInstrument(true);	
//		m_pButton->SetFlagChar(SKULL_CHAR,false);
//		m_pButton->SetFlag(true,false);
		m_pButton->put_FaceColor(COLOR_ERROR);
		m_pPropertySheet->m_pCloseButton->SetFaceColor(COLOR_ERROR);
		m_pPropertySheet->WriteToFile(TO_CEV | TO_PFM, TYPE_COMP, NULL, "53320 WRITE FAILURE on JSR file\n");
		break;

	case 9810:
		if (m_bPause) 
		{
			m_bIsPaused = true;
			m_pButton->put_FaceColor(COLOR_PAUSE);
			m_pPropertySheet->m_pCloseButton->SetFaceColor(COLOR_PAUSE);
		}
		else
		{	
			m_bIsPaused = false;
			m_dCurrent_State = 1000;
		}
		break;

	case 9900:
		if (m_bGoodRegister)
			m_dCurrent_State = 1000;
		else
		{
			m_dCurrent_State = 9900;
			m_pButton->SetErrorIcon_Bomb();
			m_pButton->ShowIcon_Error(VARIANT_TRUE);
			m_pButton->put_FaceColor(COLOR_ERROR);
			m_pPropertySheet->m_pCloseButton->SetFaceColor(COLOR_ERROR);
		}
		break;
	default:
		m_pPropertySheet->UpdateSummary("State Machine Failure");
		m_pPropertySheet->WriteToFile(TO_PFM | TO_CEV, TYPE_COMP, NULL,"53330 State Machine Failure\n");
		m_dCurrent_State = 1000;
	}
	return 0;
}
DWORD
InitializeConfiguration()
/*++

Routine Description:

    This function constructs path to Configuration File and reads the policy.

Arguments:

    None.

Return Value:

    ERROR_SUCCESS on success. On failure appropriate Win32 Error Code is 
    returned.

--*/
{
    DWORD dwError = ERROR_SUCCESS;
    HRESULT hr = S_OK;
    ULONG uFilter = PXE_PROV_FILTER_PXE_ONLY;
    WCHAR wszPolicy[8] = { 0 };

    //
    // Create path to configuration file. Configuration file is placed in the
    // same directory as the Filter Provider DLL, and its name is always
    // <name of dll>.filter.ini.
    //
    if (!GetModuleFileName((HMODULE) g_hInstance,
                           g_wszConfigurationFile,
                           NUMELEM(g_wszConfigurationFile)))
    {
        dwError = GetLastError();
        goto Cleanup;
    }

    //
    // Append suffix to get the Configuration File name.
    //
    hr = StringCchCat(g_wszConfigurationFile,
                      NUMELEM(g_wszConfigurationFile),
                      FILTER_CONFIG_FILE_SUFFIX);
    if (FAILED(hr))
    {
        dwError = ERROR_BUFFER_OVERFLOW;
        goto Cleanup;
    }

    //
    // Make sure the configuration file exists.
    //
    if (GetFileAttributes(g_wszConfigurationFile) == INVALID_FILE_ATTRIBUTES)
    {
        dwError = GetLastError();
        goto Cleanup;
    }

    //
    // Read the Policy. This is defined in the 'Configuration' section, using 
    // the 'Policy' key.
    //
    if (GetPrivateProfileString(CONFIGURATION_SECTION,
                                CONFIGURATION_POLICY_KEY,
                                NULL,
                                wszPolicy,
                                NUMELEM(wszPolicy),
                                g_wszConfigurationFile) == 0 ||
        wszPolicy[0] == 0)
    {
        dwError = ERROR_FILE_NOT_FOUND;
        goto Cleanup;
    }

    //
    // Validate Policy.
    //
    g_uFilterPolicy = _wtoi(wszPolicy);

    switch(g_uFilterPolicy)
    {
    case VAL_FILTER_POLICY_DENY:
    case VAL_FILTER_POLICY_ALLOW:
        break;

    default:
        dwError = ERROR_INVALID_DATA;
        goto Cleanup;
    }

    //
    // Log Policy.
    //
    PxeTrace(g_hFilterProvider,
             PXE_TRACE_INFO,
             L"Filter Policy: %s",
             (g_uFilterPolicy == VAL_FILTER_POLICY_DENY) ? 
                L"Exclude" : L"Include");

Cleanup:
    return dwError;
}
Example #19
0
void Pulse()
{
	if (!ppCharSpawn || !pCharSpawn) return;
	PSPAWNINFO pCharOrMount = NULL;
	PCHARINFO pCharInfo = GetCharInfo();
	PSPAWNINFO pChar = pCharOrMount = (PSPAWNINFO)pCharSpawn;
	if (pCharInfo && pCharInfo->pSpawn) pChar = pCharInfo->pSpawn;

	static WORD LastZone = -1;

	static PSPAWNINFO pCharOld = NULL;
	static FLOAT LastX = 0.0f;
	static FLOAT LastY = 0.0f;
	static ULONGLONG LastMoveTick = 0;
	static DWORD MapDelay = 0;

	// Drop out here if we're waiting for something.
	if (!pChar || gZoning /* || gDelayZoning*/) return;
	if (!pCharInfo) {
		//DebugSpew("Pulse: no charinfo returning\n");
		return;
	}

	if ((unsigned int)GetCharInfo()->charinfo_info & 0x80000000) return;

	if (pChar != pCharOld && WereWeZoning)
	{
		WereWeZoning = FALSE;
		pCharOld = pChar;
		gFaceAngle = 10000.0f;
		gLookAngle = 10000.0f;
		gbMoving = FALSE;
		LastX = pChar->X;
		LastY = pChar->Y;
		LastMoveTick = MQGetTickCount64();
		EnviroTarget.Name[0] = 0;
		pGroundTarget = 0;
		DoorEnviroTarget.Name[0] = 0;
		DoorEnviroTarget.DisplayedName[0] = 0;
		pDoorTarget = 0;

		// see if we're on a pvp server
		if (!_strnicmp(EQADDR_SERVERNAME, "tallon", 6) || !_strnicmp(EQADDR_SERVERNAME, "vallon", 6))
		{
			PVPServer = PVP_TEAM;
		}
		else if (!_strnicmp(EQADDR_SERVERNAME, "sullon", 6))
		{
			PVPServer = PVP_SULLON;
		}
		else if (!_strnicmp(EQADDR_SERVERNAME, "rallos", 6))
		{
			PVPServer = PVP_RALLOS;
		}
		else
			PVPServer = PVP_NONE;
		srand((unsigned int)time(NULL) + (unsigned int)GetCurrentProcessId()); // reseed
		Benchmark(bmPluginsOnZoned, PluginsZoned());
		
	}
	else if ((LastX != pChar->X) || (LastY != pChar->Y) || LastMoveTick>MQGetTickCount64() - 100) {
		if ((LastX != pChar->X) || (LastY != pChar->Y)) LastMoveTick = MQGetTickCount64();
		gbMoving = TRUE;
		LastX = pChar->X;
		LastY = pChar->Y;
	}
	else {
		gbMoving = FALSE;
	}
	if (!pTarget)
		gTargetbuffs = FALSE;

	if (gbDoAutoRun && pChar && pCharInfo) {
		gbDoAutoRun = FALSE;
#ifndef EMU
		InitKeyRings();
#endif
		CHAR szServerAndName[MAX_STRING] = { 0 };
		CHAR szAutoRun[MAX_STRING] = { 0 };
		PCHAR pAutoRun = szAutoRun;
		/* autorun for everyone */
		GetPrivateProfileString("AutoRun", "ALL", "", szAutoRun, MAX_STRING, gszINIFilename);
		while (pAutoRun[0] == ' ' || pAutoRun[0] == '\t') pAutoRun++;
		if (szAutoRun[0] != 0) DoCommand(pChar, pAutoRun);
		/* autorun for toon */
		ZeroMemory(szAutoRun, MAX_STRING); pAutoRun = szAutoRun;
		sprintf_s(szServerAndName, "%s.%s", EQADDR_SERVERNAME, pCharInfo->Name);
		GetPrivateProfileString("AutoRun", szServerAndName, "", szAutoRun, MAX_STRING, gszINIFilename);
		while (pAutoRun[0] == ' ' || pAutoRun[0] == '\t') pAutoRun++;
		if (szAutoRun[0] != 0) DoCommand(pChar, pAutoRun);
	}

	if ((gFaceAngle != 10000.0f) || (gLookAngle != 10000.0f)) {
		TurnNotDone = FALSE;
		if (gFaceAngle != 10000.0f) {
			if (abs((INT)(pCharOrMount->Heading - gFaceAngle)) < 10.0f) {
				pCharOrMount->Heading = (FLOAT)gFaceAngle;
				pCharOrMount->SpeedHeading = 0.0f;
				gFaceAngle = 10000.0f;
			}
			else {
				TurnNotDone = TRUE;
				DOUBLE c1 = pCharOrMount->Heading + 256.0f;
				DOUBLE c2 = gFaceAngle;
				if (c2<pChar->Heading) c2 += 512.0f;
				DOUBLE turn = (DOUBLE)(rand() % 200) / 10;
				if (c2<c1) {
					pCharOrMount->Heading += (FLOAT)turn;
					pCharOrMount->SpeedHeading = 12.0f;
					if (pCharOrMount->Heading >= 512.0f) pCharOrMount->Heading -= 512.0f;
				}
				else {
					pCharOrMount->Heading -= (FLOAT)turn;
					pCharOrMount->SpeedHeading = -12.0f;
					if (pCharOrMount->Heading<0.0f) pCharOrMount->Heading += 512.0f;
				}
			}
		}

		if (gLookAngle != 10000.0f) {
			if (abs((INT)(pChar->CameraAngle - gLookAngle)) < 5.0f) {
				pChar->CameraAngle = (FLOAT)gLookAngle;
				gLookAngle = 10000.0f;
				TurnNotDone = FALSE;
			}
			else {
				TurnNotDone = TRUE;
				FLOAT c1 = pChar->CameraAngle;
				FLOAT c2 = (FLOAT)gLookAngle;

				DOUBLE turn = (DOUBLE)(rand() % 200) / 20;
				if (c1<c2) {
					pChar->CameraAngle += (FLOAT)turn;
					if (pChar->CameraAngle >= 128.0f) pChar->CameraAngle -= 128.0f;
				}
				else {
					pChar->CameraAngle -= (FLOAT)turn;
					if (pChar->CameraAngle <= -128.0f) pChar->CameraAngle += 128.0f;
				}
			}
		}

		if (TurnNotDone) {
			bRunNextCommand = FALSE;
			IsMouseWaiting();
			return;
		}
	}
}
Example #20
0
// 获得Firefox的下载目录
BOOL bigfilehelper::GetFirefoxDownloadDirs(std::vector<CString>& vDirs)
{
    WCHAR szPath[MAX_PATH] = {0};
    BOOL bRet = FALSE;
    CString szPathFull;
    CString szPathFullEx;
    CString szTarget;
    CString strPath = L"";
    int nPos = -1;
    WCHAR szAppDataPath[MAX_PATH] = { 0 };
    WinVersion winVer;

    winVer = KGetWinVersion();

    if(WINVERSION_WIN7 == winVer)
    {
        bRet = SHGetSpecialFolderPath(NULL, szAppDataPath, CSIDL_PERSONAL, FALSE);
        if(bRet)
        {
            CString tmpdir(szAppDataPath);
            tmpdir = tmpdir.Left(tmpdir.ReverseFind(L'\\'));
            tmpdir += L"\\downloads";
            if(tmpdir.GetAt(0)==GetSystemDrive())
                vDirs.push_back(tmpdir);
        }

    }
    else
    {
        bRet = SHGetSpecialFolderPath(NULL, szAppDataPath, CSIDL_PERSONAL, FALSE);
        if(bRet)
        {
            wcscat(szAppDataPath,L"\\下载");
            if(szAppDataPath[0]==GetSystemDrive())
                vDirs.push_back(szAppDataPath);
        }
    }

    bRet = SHGetSpecialFolderPath(NULL, szPath, CSIDL_APPDATA, FALSE);
    szPathFull = szPath;
    szPathFullEx = szPath;
    szPathFullEx += _T("\\Mozilla\\Firefox");
    szPathFull += _T("\\Mozilla\\Firefox\\profiles.ini");

    WCHAR szRecord[MAX_PATH] = {0};
    std::vector<std::wstring> vLogCache;
    std::vector<std::wstring>::iterator itor;

    GetPrivateProfileString(L"Profile0", L"Path", NULL, szRecord, MAX_PATH - 1, szPathFull);

    szPathFullEx += L"\\";
    szPathFullEx += szRecord;

    szPathFullEx += L"\\prefs.js";

    const WCHAR* Point = NULL;
    HRESULT hrRet = E_FAIL;
    std::vector<std::wstring> vcStrline;
    BYTE* pBuf = NULL;
    FILE* pFile = NULL;
    DWORD dwRealReadSize = 0;

    DWORD dwFileSize  = _DoGetFileSizeByFileName(szPathFullEx);
    if (dwFileSize <= 0)
    {
        hrRet = E_FAIL;
        goto _Exit;
    }

    pBuf = new BYTE[dwFileSize * 2 + 2];
    if (!pBuf)
    {
        hrRet = E_OUTOFMEMORY;
        goto _Exit;
    }

    ::ZeroMemory(pBuf, dwFileSize * 2 + 2);

    pFile = ::_wfopen(szPathFullEx, L"rt,ccs=UTF-8");
    if (!pFile)
    {
        hrRet = E_FAIL;
        goto _Exit;
    }

    dwRealReadSize = (DWORD)::fread(pBuf, sizeof(WCHAR), dwFileSize, pFile);
    if (dwRealReadSize == 0)
    {
        hrRet = E_FAIL;
        goto _Exit;
    }

    WCHAR* pszInfo = (WCHAR*)pBuf;

    DWORD dwLineCount = _DoGetLineByBuf(pszInfo, (DWORD)::wcslen(pszInfo), vLogCache);

    for (itor = vLogCache.begin(); itor != vLogCache.end(); itor++)
    {
        szTarget = (*itor).c_str();
        nPos = szTarget.Find(L"browser.download.dir");
        if (nPos != -1)
        {
            nPos = szTarget.Find(L",");
            szTarget = szTarget.Right(szTarget.GetLength() - nPos - 3);
            nPos = szTarget.Find(L"\"");
            szTarget = szTarget.Left(nPos);
            break;
        }
    }
    if (_wcsicmp(szTarget, L"") == 0)
    {
        return FALSE;
    }

    for (int nIndex=0; nIndex<szTarget.GetLength();)
    {
        if(szTarget.GetAt(nIndex)==L'\\'&&szTarget.GetAt(nIndex+1)==L'\\')
        {
            strPath += L"\\";
            nIndex += 2;
        }
        else
        {
            strPath += szTarget.GetAt(nIndex);
            nIndex++;
        }

    }
    if(strPath.GetAt(0)==GetSystemDrive()||strPath[0]==GetSystemDrive()-32||strPath[0]==GetSystemDrive()+32)
        vDirs.push_back(strPath);
    else goto _Exit;
    hrRet = S_OK;

_Exit:

    if (pBuf)
    {
        delete []pBuf;
        pBuf = NULL;
    }
    if (pFile)
    {
        fclose(pFile);
        pFile = NULL;
    }
    return TRUE;
}
Example #21
0
void Restore_safemode()
{
	OSVERSIONINFO OSversion;	
	OSversion.dwOSVersionInfoSize=sizeof(OSVERSIONINFO);
	GetVersionEx(&OSversion);
	if(OSversion.dwMajorVersion<6)
		{
			char drivepath[150];
			char systemdrive[150];
			char stringvalue[512];
			GetEnvironmentVariable("SYSTEMDRIVE", systemdrive, 150);
			strcat (systemdrive,"/boot.ini");
			GetPrivateProfileString("boot loader","default","",drivepath,150,systemdrive);
			if (strlen(drivepath)==0) return;
			GetPrivateProfileString("operating systems",drivepath,"",stringvalue,512,systemdrive);
			if (strlen(stringvalue)==0) return;
			char* p = strrchr(stringvalue, '/');
			if (p == NULL) return;
				*p = '\0';
			WritePrivateProfileString("operating systems",drivepath,stringvalue,systemdrive);		
			SetFileAttributes(systemdrive,FILE_ATTRIBUTE_READONLY);
		}
	else
		{
#ifdef _X64
			char systemroot[150];
			GetEnvironmentVariable("SystemRoot", systemroot, 150);
			char exe_file_name[MAX_PATH];
			char parameters[MAX_PATH];
			strcpy(exe_file_name,systemroot);
			strcat(exe_file_name,"\\system32\\");
			strcat(exe_file_name,"bcdedit.exe");
			strcpy(parameters,"/deletevalue safeboot");
			SHELLEXECUTEINFO shExecInfo;
			shExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
			shExecInfo.fMask = 0;
			shExecInfo.hwnd = GetForegroundWindow();
			shExecInfo.lpVerb = "runas";
			shExecInfo.lpFile = exe_file_name;
			shExecInfo.lpParameters = parameters;
			shExecInfo.lpDirectory = NULL;
			shExecInfo.nShow = SW_HIDE;
			shExecInfo.hInstApp = NULL;
			ShellExecuteEx(&shExecInfo);
#else
			typedef BOOL (WINAPI *LPFN_Wow64DisableWow64FsRedirection)(PVOID* OldValue);
			typedef BOOL (WINAPI *LPFN_Wow64RevertWow64FsRedirection)(PVOID OldValue);
			PVOID OldValue;  
			LPFN_Wow64DisableWow64FsRedirection pfnWow64DisableWowFsRedirection = (LPFN_Wow64DisableWow64FsRedirection)GetProcAddress(GetModuleHandle("kernel32"),"Wow64DisableWow64FsRedirection");
			LPFN_Wow64RevertWow64FsRedirection pfnWow64RevertWow64FsRedirection = (LPFN_Wow64RevertWow64FsRedirection)GetProcAddress(GetModuleHandle("kernel32"),"Wow64RevertWow64FsRedirection");
			if (pfnWow64DisableWowFsRedirection && pfnWow64RevertWow64FsRedirection)  ///win32 on x64 system
			{
				if(TRUE == pfnWow64DisableWowFsRedirection(&OldValue))
					{
						char systemroot[150];
						GetEnvironmentVariable("SystemRoot", systemroot, 150);
						char exe_file_name[MAX_PATH];
						char parameters[MAX_PATH];
						strcpy(exe_file_name,systemroot);
						strcat(exe_file_name,"\\system32\\");
						strcat(exe_file_name,"bcdedit.exe");
						strcpy(parameters,"/deletevalue safeboot");
						SHELLEXECUTEINFO shExecInfo;
						shExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
						shExecInfo.fMask = 0;
						shExecInfo.hwnd = GetForegroundWindow();
						shExecInfo.lpVerb = "runas";
						shExecInfo.lpFile = exe_file_name;
						shExecInfo.lpParameters = parameters;
						shExecInfo.lpDirectory = NULL;
						shExecInfo.nShow = SW_HIDE;
						shExecInfo.hInstApp = NULL;
						ShellExecuteEx(&shExecInfo);
						pfnWow64RevertWow64FsRedirection(OldValue);
					}
				else
				{
					char systemroot[150];
					GetEnvironmentVariable("SystemRoot", systemroot, 150);
					char exe_file_name[MAX_PATH];
					char parameters[MAX_PATH];
					strcpy(exe_file_name,systemroot);
					strcat(exe_file_name,"\\system32\\");
					strcat(exe_file_name,"bcdedit.exe");
					strcpy(parameters,"/deletevalue safeboot");
					SHELLEXECUTEINFO shExecInfo;
					shExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
					shExecInfo.fMask = 0;
					shExecInfo.hwnd = GetForegroundWindow();
					shExecInfo.lpVerb = "runas";
					shExecInfo.lpFile = exe_file_name;
					shExecInfo.lpParameters = parameters;
					shExecInfo.lpDirectory = NULL;
					shExecInfo.nShow = SW_HIDE;
					shExecInfo.hInstApp = NULL;
					ShellExecuteEx(&shExecInfo);
				}
			}
			else  //win32 on W32
			{
				char systemroot[150];
				GetEnvironmentVariable("SystemRoot", systemroot, 150);
				char exe_file_name[MAX_PATH];
				char parameters[MAX_PATH];
				strcpy(exe_file_name,systemroot);
				strcat(exe_file_name,"\\system32\\");
				strcat(exe_file_name,"bcdedit.exe");
				strcpy(parameters,"/deletevalue safeboot");
				SHELLEXECUTEINFO shExecInfo;
				shExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
				shExecInfo.fMask = 0;
				shExecInfo.hwnd = GetForegroundWindow();
				shExecInfo.lpVerb = "runas";
				shExecInfo.lpFile = exe_file_name;
				shExecInfo.lpParameters = parameters;
				shExecInfo.lpDirectory = NULL;
				shExecInfo.nShow = SW_HIDE;
				shExecInfo.hInstApp = NULL;
				ShellExecuteEx(&shExecInfo);
			}
#endif
		}
}
Example #22
0
LRESULT CMainFrame::OnCreate(LPCREATESTRUCT lpcs)
{
	hWndMainFrame = this->m_hWnd;

	TCHAR moduleDir[MAX_PATH] = {0};
	TCHAR fileurl[MAX_PATH] = _T("file://");
	LPTSTR pathpart = fileurl + ::lstrlen(fileurl);
	DWORD pathpartlen = MAX_PATH - ::lstrlen(fileurl);

	// Get the autorun.exe's path
	ATLENSURE( ::GetModuleFileName(NULL, moduleDir, MAX_PATH) );
	::PathRemoveFileSpec(moduleDir);

	TCHAR autoRunInfPath[MAX_PATH] = {0};
	ATLENSURE_SUCCEEDED( ::StringCchCopy(autoRunInfPath, MAX_PATH, moduleDir) );
	::PathAppend(autoRunInfPath, _T("AUTORUN.INF"));

	// Read [HTML] HTML=...
	TCHAR home[MAX_PATH] = {0};
	GetPrivateProfileString(_T("HTML"), _T("HOME"), _T(""),  home, MAX_PATH, autoRunInfPath);
	if (::lstrlen(home) == 0)
	{
		PostMessage(WM_CLOSE);
		::ShellExecute(NULL, _T("open"), _T("."), NULL, NULL, SW_SHOW);
		return TRUE;
	}


	LPCTSTR url = _T("");
	if (home[0] == _T('r') && 
		home[1] == _T('e') && 
		home[2] == _T('s') && 
		home[3] == _T(':') &&
		home[4] == _T('/') &&
		home[5] == _T('/'))
	{
		url = home;
	}
	else
	{
		::StringCchCopy(pathpart, pathpartlen, moduleDir);
		::PathAppend(pathpart, home);
		url = fileurl;
	}

	//TODO: Replace with a URL of your choice
	m_hWndClient = m_view.Create(
		m_hWnd, 
		rcDefault, 
		_T(""), 
		WS_BORDER | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, 
		0,
		0U, 
		const_cast<LPTSTR>(url));

	// register object for message filtering and idle updates
	CMessageLoop* pLoop = _Module.GetMessageLoop();
	ATLASSERT(pLoop != NULL);
	pLoop->AddMessageFilter(this);
	pLoop->AddIdleHandler(this);

	int width = GetPrivateProfileInt(_T("HTML"), _T("WIDTH"), 600, autoRunInfPath);
	int height = GetPrivateProfileInt(_T("HTML"), _T("HEIGHT"), 450, autoRunInfPath);

	if (width < 1) width = 600;
	if (height < 1) height = 450;

	ResizeClient(width, height);

	CenterWindow();

	return 0;
}
Example #23
0
BOOL CMyDataBase::ConnDB()
{


	BOOL bRes = FALSE;

	TCHAR tchHost[16];
	TCHAR tchUser[100];
	TCHAR tchPass[100];


	


	dbConn = (MYSQL *)malloc(sizeof(MYSQL));
	if(NULL == dbConn)
	{

#ifdef _MYDEBUG
		g_log.Log(LEVEL_ERROR,"Êý¾Ý¿â¾ä±úÉêÇëÄÚ´æʧ°Ü\n");

#endif
		goto CONN_TO_DB_FUNC_END;
	}

	memset(dbConn,0,sizeof(MYSQL));



	mysql_init(dbConn);


	memset(tchHost,0,sizeof(tchHost));
	memset(tchUser,0,sizeof(tchUser));
	memset(tchPass,0,sizeof(tchPass));

	GetPrivateProfileString("Config","DBHost","10.0.16.9",tchHost,16,DB_CONF_FILE);
	GetPrivateProfileString("Config","DBUser","runvista",tchUser,100,DB_CONF_FILE);
	GetPrivateProfileString("Config","DBPasswd","runco",tchPass,100,DB_CONF_FILE);

	if(!mysql_real_connect(dbConn,tchHost,tchUser,tchPass,"tspcenter",33068,NULL,0))
	{
		


#ifdef _MYDEBUG
		g_log.Log(LEVEL_ERROR,"CMydatabaseÊý¾Ý¿âÁ¬½Óʧ°Ü\n");
		g_log.Log(LEVEL_ERROR,"%s\n",mysql_error(dbConn));

#endif


		mysql_close(dbConn);
		free(dbConn);
		dbConn = NULL;

		goto CONN_TO_DB_FUNC_END;
	}

	bRes = TRUE;
	

CONN_TO_DB_FUNC_END:
	

	return bRes;

}
BOOL CEditorDoc::OnNewDocument ( )
{
	theApp.m_Debug.Write ( "CEditorDoc::OnNewDocument" );
	
	// create a new document

	// call the base class function
	if ( !COleDocument::OnNewDocument ( ) )
	{
		theApp.m_Debug.Write ( "CEditorDoc::Failed" );
		return FALSE;
	}

	

	// m_NewProject.DoModal ( );

	// string to store executable link
	TCHAR szExecutable [ MAX_PATH ];

	theApp.m_Debug.Write ( "CEditorDoc::SetCurrentDirectory" );
	
	theApp.m_Debug.Write ( theApp.m_szDirectory );
	SetCurrentDirectory ( theApp.m_szDirectory );

	// get the exe to run
	//GetPrivateProfileString ( _T ( "General" ), _T ( "Executable" ), _T ( "" ), szExecutable, MAX_PATH, _T ( "./files/editors/host/editor.ini" ) );
	GetPrivateProfileString ( _T ( "General" ), _T ( "Executable" ), _T ( "" ), szExecutable, MAX_PATH, theApp.m_szLanguage );
	
	// get pointer to frame
	CMainFrame* pFrame = ( CMainFrame* ) theApp.m_pMainWnd;

	// show library window
	pFrame->SetEntityVisible ( TRUE );

	SetTitle ( _T ( "Editor" ) );

	theApp.m_pDocumentA = this;



	if ( theApp.m_bRestart )
	{
		theApp.m_Debug.Write ( "CEditorDoc::m_bRestart" );

		//Sleep ( 250 );

		theApp.m_bAppRunning = true;
		theApp.m_bRestart  = false;

		theApp.m_DBProApplicationLaunched = false;

		SetCurrentDirectory ( theApp.m_szDirectory );

		char szExeANSI [ 255 ] = "";
		char szParamANSI [ 255 ] = "";
		CString szParamUNI;
		CString szExeUNI;

					cIPC* pIPC	= theApp.m_Message.GetIPC ( );
			char  dataA [ 255 ] = "";
			char  dataB [ 255 ] = "";
			
			pIPC->ReceiveBuffer ( &dataA [ 0 ], 1000, sizeof ( dataA ) );
			pIPC->ReceiveBuffer ( &dataB [ 0 ], 1256, sizeof ( dataB ) );

			ConvertANSIToWide ( ( BYTE* ) &dataA [ 0 ], szExeANSI,   &szExeUNI );
			ConvertANSIToWide ( ( BYTE* ) &dataB [ 0 ], szParamANSI, &szParamUNI );

		//ConvertANSIToWide ( &theApp.m_pData [ 1000 ], szExeANSI,   &szExeUNI );
		//ConvertANSIToWide ( &theApp.m_pData [ 1256 ], szParamANSI, &szParamUNI );

		// ORIGINAL WORKING CODE
		// open the exe file
		//HINSTANCE hInstance = ShellExecute ( NULL, _T ( "open" ), szExeUNI, szParamUNI, NULL, SW_HIDE   );
		//theApp.m_hInstance = hInstance;

		// 151204
		theApp.SetFileMapData ( 912, 0 );
		theApp.SetFileMapData ( 916, 0 );

		{
			

			SHELLEXECUTEINFO seinfo;

			ZeroMemory ( &seinfo, sizeof ( seinfo ) );

			seinfo.cbSize       = sizeof ( seinfo );
			seinfo.fMask        = SEE_MASK_NOCLOSEPROCESS;
			seinfo.hwnd         = NULL;
			seinfo.lpVerb       = _T ( "open" );
			seinfo.lpFile       = szExeUNI;
			seinfo.lpParameters = szParamUNI;
			seinfo.lpDirectory  = _T ( "" );
			seinfo.nShow        = SW_HIDE;
			//seinfo.nShow        = SW_SHOW;
			
			char szDebug [ 255 ] = "";

			theApp.m_Debug.Write ( "RESTART EDITOR" );

			sprintf ( szDebug, "Shell execute - executable - %s", szExeANSI   );
			theApp.m_Debug.Write ( szDebug );
			sprintf ( szDebug, "Shell execute - parameters - %s", szParamANSI );
			theApp.m_Debug.Write ( szDebug );

			theApp.m_iRecover = 0;

			cIPC* pIPC	= theApp.m_Message.GetIPC ( );
			
			BYTE dataClear [ 6144 ] = { 0 };
			
			pIPC->SendBuffer ( &dataClear [ 0 ], 0, sizeof ( dataClear ) );

			//memset ( theApp.m_pData, 0, 1024 * 6 );

			theApp.SetFileMapData ( 44, 1 );
			theApp.SetFileMapData ( 486, 1 );

			theApp.m_bDisplayMouse = TRUE;
			theApp.m_lastPoint.x = 0;
			theApp.m_lastPoint.y = 0;
			theApp.m_bEnd = FALSE;
			theApp.m_bDisable = true;
			theApp.m_bFocus = false;
			theApp.m_bEntityFocus = false;
			theApp.m_iRecover = 0;
			theApp.m_bRestart = false;

			////// 221204 ////////////////////////////////////
			/*
			while ( 1 )
			{
				bool bGame = false;

				HANDLE hSnapShot = CreateToolhelp32Snapshot ( TH32CS_SNAPPROCESS, 0 );
				PROCESSENTRY32 processInfo;
				processInfo.dwSize = sizeof ( PROCESSENTRY32 );
				int index = 0;

				while ( Process32Next ( hSnapShot, &processInfo ) != FALSE )
				{
					// 170105
					//if ( wcscmp ( processInfo.szExeFile, _T ( "FPSC-Game.exe" ) ) == 0 )
					if ( strcmp ( processInfo.szExeFile, _T ( "FPSC-Game.exe" ) ) == 0 )
					{
						bGame = true;
					}
				}

				CloseHandle ( hSnapShot );
				
				if ( bGame )
					theApp.m_Debug.Write ( "FPSC-Game.exe - running" );

				if ( !bGame )
					break;
			}
			*/
			////////////////////////////////////////////////

			////////////////////////
			{
				theApp.m_Debug.Write ( "CEditorDoc::Checking running processes" );
				
				// 010205
				while ( 1 )
				{
					CEnumProcess tmp;
					 CString s;

					tmp.SetMethod ( 0x1 );

					CEnumProcess::CProcessEntry entry;

					bool bGame = false;
					
					for (BOOL OK = tmp.GetProcessFirst(&entry); OK; OK = tmp.GetProcessNext(&entry) )
					{
						int image = 0;
						if (entry.hTask16)
						{
							s.Format("%08X (%ld)", entry.dwPID, entry.hTask16);
							image = 1;
						}
						else
							s.Format("%08X", entry.dwPID);

						TRACE(s + " %s\n", entry.lpFilename);
						
						

						{
							_strlwr ( entry.lpFilename );

							CString		process = entry.lpFilename;
							char		szTextANSI [ 255 ]	= "";
							ConvertWideToANSI ( NULL, &process, szTextANSI );

							//theApp.m_Debug.Write ( szTextANSI );

							char  seps[ ] = ".\\//";
							char* token;

							token = strtok ( szTextANSI, seps );

							while ( token != NULL )
							{
								/*
								if ( strcmp ( token, "fpsc-game" ) == 0 )
								{
									bGame = true;
								}
								*/

								if ( _strnicmp ( token, "fpsc-game", strlen ( token ) ) == 0 )
									bGame = true;

								token = strtok ( NULL, seps );
							}
						}
					}

					if ( bGame )
						theApp.m_Debug.Write ( "FPSC-game.exe - running" );

					if ( !bGame )
					{
						theApp.m_Debug.Write ( "FPSC-game.exe - not running - quit" );
						break;
					}
				}
			}
			///////////////////////

			// 170105
			theApp.m_bTestGameCancel = true;


				

			/*
		// 020205 - new
		{

			{
				STARTUPINFO si;
			    PROCESS_INFORMATION pi;
				ZeroMemory( &si, sizeof(si) );
				si.cb = sizeof(si);
				si.dwFlags = STARTF_USESHOWWINDOW;
				//si.wShowWindow = SW_SHOWDEFAULT;
				si.wShowWindow = SW_HIDE;

				DWORD dwPriority = NORMAL_PRIORITY_CLASS;

				if ( CreateProcess ( szExeANSI, szParamANSI, NULL, NULL, FALSE, dwPriority, NULL, theApp.m_szDirectory, &si, &pi ) ) 
				{
					theApp.m_DBProApplicationLaunched = true;
					theApp.m_bAppRunning = true;

					theApp.m_Debug.Write ( "Shell execute - success" );

					memcpy ( &theApp.m_DBProProcess, &pi, sizeof ( PROCESS_INFORMATION ) );

					
					//SAFE_DELETE(pDirectory);
					//CloseHandle ( pi.hThread );
					//CloseHandle ( pi.hProcess );
					//*dwExecuteFileProcess = pi.dwProcessId;
					//return TRUE;
				}
				else
				{
					theApp.m_Debug.Write ( "Shell execute - failed" );
					theApp.m_DBProApplicationLaunched = false;	
				}
			}
		}
		*/

		
			// 020205 - original
			if ( ShellExecuteEx ( &seinfo ) == TRUE )
			{
				theApp.m_DBProApplicationLaunched = true;
				theApp.m_DBProApplication		  = seinfo;

				theApp.m_hInstance = seinfo.hInstApp;
				theApp.m_bAppRunning = true;

				theApp.m_Debug.Write ( "Shell execute - success" );
			}
			else
			{
				theApp.m_Debug.Write ( "Shell execute - failed" );
				theApp.m_DBProApplicationLaunched = false;
			}
			
			if ( seinfo.hInstApp <= ( HINSTANCE ) 32 )
			{
				theApp.m_Debug.Write ( "Shell execute - invalid hinstance" );
				theApp.m_DBProApplicationLaunched = false;
			}
			
		}

		
		
		theApp.SetFileMapData ( 974, 0 );

		theApp.m_bFocus       = false;
		theApp.m_bEntityFocus = false;

	}
	else
	{
		// go to root FPSC folder
		SetCurrentDirectory ( theApp.m_szDirectory );

		// create mapeditor process
		SHELLEXECUTEINFO seinfo;
		ZeroMemory ( &seinfo, sizeof ( seinfo ) );
		seinfo.cbSize       = sizeof ( seinfo );

		// check if editor already exists (for debugging)
		HWND hEditorWnd = FindWindow ( NULL, "FPSC Map Editor" );
		if ( hEditorWnd )
		{
			// debug
			theApp.m_Debug.Write ( "ACQUIRING EDITOR" );

			// fill data from window
			seinfo.hwnd         = hEditorWnd;
			seinfo.hInstApp     = NULL;

			// set application for linkage
			theApp.m_DBProApplicationLaunched = true;
			theApp.m_DBProApplication		  = seinfo;
			theApp.m_hInstance = seinfo.hInstApp;
			theApp.m_bAppRunning = true;
			theApp.m_Debug.Write ( "ACQUIRE - success\n" );
		}
		else
		{
			// debug
			theApp.m_Debug.Write ( "LAUNCH EDITOR" );

			// prepare data for launch
			seinfo.fMask        = SEE_MASK_NOCLOSEPROCESS;
			seinfo.hwnd         = NULL;
			seinfo.lpVerb       = _T ( "open" );
			seinfo.lpFile       = szExecutable;
			seinfo.lpParameters = _T ( "" );
			seinfo.lpDirectory  = _T ( "" );
			seinfo.nShow        = SW_HIDE;

			// shell execute mapeditor
			if ( ShellExecuteEx ( &seinfo ) == TRUE )
			{
				theApp.m_DBProApplicationLaunched = true;
				theApp.m_DBProApplication		  = seinfo;

				theApp.m_hInstance = seinfo.hInstApp;
				theApp.m_bAppRunning = true;

				theApp.m_Debug.Write ( "START - success\n" );
			}
			else
			{
				theApp.m_Debug.Write ( "START - failed\n" );
				theApp.m_DBProApplicationLaunched = false;	
			}
		}
		
		// debug
		theApp.m_Debug.Write ( "FINISHED\n" );
	}

	// debug
	theApp.m_Debug.Write ( "CEditorDoc::End" );

	// complete
	return TRUE;
}
Example #25
0
void CHHMRModParam::OnModparamsApplyHHMR()
{
	//Button caption:  "Apply New HHMR Configuration To Instrument && MIC"
	if (m_pParent->Validate())
	{
		char *pName = m_pParent->m_pName;
		char *file = m_pParent->m_szIniFile;
		char temp[32];

		//if it doesn't have these in it then give it a set
		GetPrivateProfileString(pName,"CAMERA_PORT","",temp,sizeof(temp),file);
		if (strlen(temp)==0)
		{
			WritePrivateProfileString(pName,"CAMERA_PORT","LPT2",file);
			WritePrivateProfileString(pName,"CAMERA_PIN","2",file);
			WritePrivateProfileString(pName,"CAMERA_TRIGGER_TYPE","RT1",file);
//			WritePrivateProfileString(pName,"CAMERA_TRIGGER_THRESHOLD_RATE","50.00",m_pParent->m_szIniFile);
			WritePrivateProfileString(pName,"CAMERA_TRIGGER_HOLDOFF","0:0:0:10",file);
			WritePrivateProfileString(pName,"CAMERA_TRIGGER_SUPPRESS","0:0:5:0",file);
		}

		//get each of the HHMR specific dialog item and save them in the ini file
		GetDlgItemText(IDC_HHMRMODPARAMS_CT_UNITS,temp,sizeof(temp));
		if (strlen(temp) < 1)
		{
			strcpy(temp,CT_UNITS_SPIN_DEF);
			SetDlgItemText(IDC_HHMRMODPARAMS_CT_UNITS,temp);
		}
		WritePrivateProfileString(pName, "COUNTTIMEUNIT", temp, file);

		//get exponential of count time
//		GetDlgItemText(IDC_HHMRMODPARAMS_CT_EXP,temp,sizeof(temp));
//		if (strlen(temp) < 1)
//		{
//			strcpy(temp, CT_EXP_SPIN_DEF);
//			SetDlgItemText(IDC_HHMRMODPARAMS_CT_EXP,temp);
//		}
//		WritePrivateProfileString(pName, "COUNTTIMEEXP",temp,file);

		//get predelay
		int select = ((CComboBox*)GetDlgItem(IDC_HHMRMODPARAMS_PREDELAY))->GetCurSel();
		sprintf(temp,"%0X",select);
		WritePrivateProfileString(pName,"PREDELAY",temp,file);

		//get gate width
		GetDlgItemText(IDC_HHMRMODPARAMS_GATEWIDTH,temp,sizeof(temp));
		WritePrivateProfileString(pName,"GATEWIDTH",temp,file);

		//get high voltage
		GetDlgItemText(IDC_HHMRMODPARAMS_HIGHV,temp,sizeof(temp));
		WritePrivateProfileString(pName,"HIGHV",temp,file);

		//tell parent instrument to do the jsr configurations
		m_pParent->PostMessage(uIDC_RECEIVE,RESETUP,NULL);
		m_pParent->UpdateParams(true);

		//tell the graphic window to update params
		char szTemp[_MAX_PATH];
		strcpy(szTemp,pName);
		strcat(szTemp," Watcher");
		CWnd * pcWnd = FindWindow(NULL,szTemp);
		if (pcWnd)
			pcWnd->PostMessage(UPDATE_MESSAGE,1,0);

	}
}
Example #26
0
BOOL Profile::GetString(const TCHAR *szOption, TCHAR *buf, int cchLen)
{
    return GetPrivateProfileString(_szSectionName, szOption, 0, buf, cchLen, _szFileName) != 0;
}
Example #27
0
INT_PTR CALLBACK InputPageDialogProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
  // Mouse actions
  struct {
    int control;
    wchar_t *option;
  } mouse_buttons[] = {
    { IDC_LMB, L"LMB" },
    { IDC_MMB, L"MMB" },
    { IDC_RMB, L"RMB" },
    { IDC_MB4, L"MB4" },
    { IDC_MB5, L"MB5" },
  };
  struct action {
    wchar_t *action;
    wchar_t *l10n;
  };
  struct action mouse_actions[] = {
    { L"Move",        l10n->input_actions_move },
    { L"Resize",      l10n->input_actions_resize },
    { L"Close",       l10n->input_actions_close },
    { L"Minimize",    l10n->input_actions_minimize },
    { L"Lower",       l10n->input_actions_lower },
    { L"AlwaysOnTop", l10n->input_actions_alwaysontop },
    { L"Center",      l10n->input_actions_center },
    { L"Nothing",     l10n->input_actions_nothing },
  };

  // Scroll
  struct action scroll_actions[] = {
    { L"AltTab",       l10n->input_actions_alttab },
    { L"Volume",       l10n->input_actions_volume },
    { L"Transparency", l10n->input_actions_transparency },
    { L"Lower",        l10n->input_actions_lower },
    { L"Nothing",      l10n->input_actions_nothing },
  };

  // Hotkeys
  struct {
    int control;
    int vkey;
  } hotkeys[] = {
    { IDC_LEFTALT,     VK_LMENU },
    { IDC_RIGHTALT,    VK_RMENU },
    { IDC_LEFTWINKEY,  VK_LWIN },
    { IDC_RIGHTWINKEY, VK_RWIN },
    { IDC_LEFTCTRL,    VK_LCONTROL },
    { IDC_RIGHTCTRL,   VK_RCONTROL },
  };

  if (msg == WM_INITDIALOG) {
    wchar_t txt[50];
    int i;
    // Hotkeys
    unsigned int temp;
    int numread;
    GetPrivateProfileString(L"Input", L"Hotkeys", L"A4 A5", txt, ARRAY_SIZE(txt), inipath);
    wchar_t *pos = txt;
    while (*pos != '\0' && swscanf(pos,L"%02X%n",&temp,&numread) != EOF) {
      pos += numread;
      // What key was that?
      for (i=0; i < ARRAY_SIZE(hotkeys); i++) {
        if (temp == hotkeys[i].vkey) {
          Button_SetCheck(GetDlgItem(hwnd,hotkeys[i].control), BST_CHECKED);
          break;
        }
      }
    }
  }
  else if (msg == WM_COMMAND) {
    int id = LOWORD(wParam);
    int event = HIWORD(wParam);
    wchar_t txt[50] = L"";
    int i;
    if (event == CBN_SELCHANGE) {
      HWND control = GetDlgItem(hwnd, id);
      // Mouse actions
      for (i=0; i < ARRAY_SIZE(mouse_buttons); i++) {
        if (id == mouse_buttons[i].control) {
          int j = ComboBox_GetCurSel(control);
          WritePrivateProfileString(L"Input", mouse_buttons[i].option, mouse_actions[j].action, inipath);
          break;
        }
      }
      // Scroll
      if (id == IDC_SCROLL) {
        int j = ComboBox_GetCurSel(control);
        if (!vista && !wcscmp(scroll_actions[j].action,L"Volume")) {
          MessageBox(NULL, L"The Volume action only works on Vista and later. Sorry!", APP_NAME, MB_ICONINFORMATION|MB_OK|MB_TASKMODAL);
          GetPrivateProfileString(L"Input", L"Scroll", L"Nothing", txt, ARRAY_SIZE(txt), inipath);
          for (i=0; wcscmp(txt,scroll_actions[i].action) && i < ARRAY_SIZE(scroll_actions)-1; i++) {}
          ComboBox_SetCurSel(control, i);
        }
        else {
          WritePrivateProfileString(L"Input", L"Scroll", scroll_actions[j].action, inipath);
        }
      }
    }
    else if (LOWORD(wParam) == IDC_LOWERWITHMMB) {
      int val = Button_GetCheck(GetDlgItem(hwnd, IDC_LOWERWITHMMB));
      WritePrivateProfileString(L"Input", L"LowerWithMMB", _itow(val,txt,10), inipath);
    }
    else {
      // Hotkeys
      int vkey = 0;
      for (i=0; i < ARRAY_SIZE(hotkeys); i++) {
        if (wParam == hotkeys[i].control) {
          vkey = hotkeys[i].vkey;
          break;
        }
      }
      if (!vkey) return FALSE;

      wchar_t keys[50];
      GetPrivateProfileString(L"Input", L"Hotkeys", L"", keys, ARRAY_SIZE(keys), inipath);
      int add = Button_GetCheck(GetDlgItem(hwnd,wParam));
      if (add) {
        if (*keys != '\0') {
          wcscat(keys, L" ");
        }
        swprintf(txt, L"%s%02X", keys, vkey);
      }
      else {
        unsigned int temp;
        int numread;
        wchar_t *pos = keys;
        while (*pos != '\0' && swscanf(pos,L"%02X%n",&temp,&numread) != EOF) {
          if (temp == vkey) {
            wcsncpy(txt, keys, pos-keys);
            wcscat(txt, pos+numread);
            break;
          }
          pos += numread;
        }
      }
      WritePrivateProfileString(L"Input", L"Hotkeys", txt, inipath);
    }
    UpdateSettings();
  }
  else if (msg == WM_NOTIFY) {
    LPNMHDR pnmh = (LPNMHDR)lParam;
    if (pnmh->code == PSN_SETACTIVE) {
      wchar_t txt[50];
      int i, j, sel;

      // Mouse actions
      for (i=0; i < ARRAY_SIZE(mouse_buttons); i++) {
        HWND control = GetDlgItem(hwnd, mouse_buttons[i].control);
        ComboBox_ResetContent(control);
        GetPrivateProfileString(L"Input", mouse_buttons[i].option, L"Nothing", txt, ARRAY_SIZE(txt), inipath);
        sel = ARRAY_SIZE(mouse_actions)-1;
        for (j=0; j < ARRAY_SIZE(mouse_actions); j++) {
          ComboBox_AddString(control, mouse_actions[j].l10n);
          if (!wcscmp(txt,mouse_actions[j].action)) {
            sel = j;
          }
        }
        ComboBox_SetCurSel(control, sel);
      }

      // Scroll
      HWND control = GetDlgItem(hwnd, IDC_SCROLL);
      ComboBox_ResetContent(control);
      GetPrivateProfileString(L"Input", L"Scroll", L"Nothing", txt, ARRAY_SIZE(txt), inipath);
      sel = ARRAY_SIZE(scroll_actions)-1;
      for (j=0; j < ARRAY_SIZE(scroll_actions); j++) {
        ComboBox_AddString(control, scroll_actions[j].l10n);
        if (!wcscmp(txt,scroll_actions[j].action)) {
          sel = j;
        }
      }
      ComboBox_SetCurSel(control, sel);

      // Update text
      SetDlgItemText(hwnd, IDC_MOUSE_BOX,      l10n->input_mouse_box);
      SetDlgItemText(hwnd, IDC_LMB_HEADER,     l10n->input_mouse_lmb);
      SetDlgItemText(hwnd, IDC_MMB_HEADER,     l10n->input_mouse_mmb);
      SetDlgItemText(hwnd, IDC_RMB_HEADER,     l10n->input_mouse_rmb);
      SetDlgItemText(hwnd, IDC_MB4_HEADER,     l10n->input_mouse_mb4);
      SetDlgItemText(hwnd, IDC_MB5_HEADER,     l10n->input_mouse_mb5);
      SetDlgItemText(hwnd, IDC_SCROLL_HEADER,  l10n->input_mouse_scroll);
      SetDlgItemText(hwnd, IDC_LOWERWITHMMB,   l10n->input_mouse_lowerwithmmb);
      SetDlgItemText(hwnd, IDC_HOTKEYS_BOX,    l10n->input_hotkeys_box);
      SetDlgItemText(hwnd, IDC_LEFTALT,        l10n->input_hotkeys_leftalt);
      SetDlgItemText(hwnd, IDC_RIGHTALT,       l10n->input_hotkeys_rightalt);
      SetDlgItemText(hwnd, IDC_LEFTWINKEY,     l10n->input_hotkeys_leftwinkey);
      SetDlgItemText(hwnd, IDC_RIGHTWINKEY,    l10n->input_hotkeys_rightwinkey);
      SetDlgItemText(hwnd, IDC_LEFTCTRL,       l10n->input_hotkeys_leftctrl);
      SetDlgItemText(hwnd, IDC_RIGHTCTRL,      l10n->input_hotkeys_rightctrl);
      SetDlgItemText(hwnd, IDC_HOTKEYS_MORE,   l10n->input_hotkeys_more);
    }
  }

  LinkProc(hwnd, msg, wParam, lParam);
  return FALSE;
}
Example #28
0
std::string GetPrivateProfileStdString(LPCSTR lpAppName,LPCSTR lpKeyName,LPCSTR lpDefault)
{
	static char buf[65536];
	GetPrivateProfileString(lpAppName, lpKeyName, lpDefault, buf, 65536, IniName);
	return buf;
}
Example #29
0
//---------------------------------------------------------------------------
// InitializeInstance
//
// Performs a per-instance initialization of WTD.  The WTD Command Line
// parser is first called - if a valid command line was given, it does NOT
// RETURN from that call, since the WTD BASIC engine is invoked straight
// from there, and then the program exits.
//
// However, if an invalid command line (or none at all) is given, we come
// back here and create the frame window, and an MDI child.
//
// RETURNS:     TRUE if successful, or FALSE if not
//---------------------------------------------------------------------------
BOOL  APIENTRY InitializeInstance(LPSTR lpCmdLine, INT nCmdShow)
{
    extern HWND  hwndMDIClient;
    CHAR         sz[320];
    CHAR         *def = "",
                 *szCreate = "-2147450880"; /* this is really 0x80008000 */
    INT          i, j, FrameState, VPstate, flags, len;
    INT          actions[3] = {IDD_NEVER, IDD_ALWAYS, IDD_QUERY};
    HANDLE       *hScr;

#ifdef DEBUG
    auxport = 0;
#endif

    // Set up the helpfile name and the INI file name
    //-----------------------------------------------------------------------
    SetHelpFileName ();
    len = GetModuleFileName (GetModuleHandle (szModName), szIni,
                             sizeof(szIni));
    while (szIni[len] != '\\')
        len--;
    szIni[len+1] = 0;
    strcat (szIni, szIniName);
    UseIniInclude ("INCLUDE", szDrvr, szIni);

    // Initialize the pre-defined symbol space.
    //-----------------------------------------------------------------------
    for (i=0; i<16; i++)
        DefPtrs[i] = DefSym[i];

    // Get Window state information (max'd, hidden, etc)
    //-----------------------------------------------------------------------
    FrameState = GetPrivateProfileInt (szDrvr, "FrameState", 0, szIni);
    VPstate = GetPrivateProfileInt (szDrvr, "VPState", 0, szIni);
    ChildState = GetPrivateProfileInt (szDrvr, "MDIState", 0, szIni);

    GetPrivateProfileString (szDrvr, "FramePos", szCreate, sz, 80, szIni);
    Frx = LOWORD(atol (sz));
    Fry = HIWORD(atol (sz));

    GetPrivateProfileString (szDrvr, "FrameSize", szCreate, sz, 80, szIni);
    Frh = LOWORD(atol (sz));
    Frw = HIWORD(atol (sz));

    GetPrivateProfileString (szDrvr, "VPPos", szCreate, sz, 80, szIni);
    VPx = LOWORD(atol (sz));
    VPy = HIWORD(atol (sz));

    GetPrivateProfileString (szDrvr, "VPSize", szCreate, sz, 80, szIni);
    VPh = LOWORD(atol (sz));
    VPw = HIWORD(atol (sz));

    // Read the "Get XY-Coords" dialog settings
    //-----------------------------------------------------------------------
    flags = GetPrivateProfileInt (szXY, "Opts", XY_VIEWPORT |
                                                XY_STATBAR,
                                                szIni);
    fInsEdit = flags & XY_INSEDIT;
    fInsClip = flags & XY_INSCLIP;
    fVP      = flags & XY_VIEWPORT;
    fStatbar = flags & XY_STATBAR;
    iFmtIndex = GetPrivateProfileInt (szXY, "Format", 0, szIni);

    // Read the search/replace vars
    //-----------------------------------------------------------------------
    GetPrivateProfileString (szDrvr, "SR", def, sz, 80, szIni);
    SRx = LOWORD(atol (sz));
    SRy = HIWORD(atol (sz));

    GetPrivateProfileString (szDrvr, "Srch", def, szSrchbuf,
                             sizeof(szSrchbuf), szIni);
    GetPrivateProfileString (szDrvr, "Repl", def, szReplbuf,
                             sizeof(szSrchbuf), szIni);

    // Get the environment dialog options
    //-----------------------------------------------------------------------
    flags = GetPrivateProfileInt (szDrvr, "EnvFlags", ENV_SAVEASK |
                                                   ENV_CMPDLG |
                                                   ENV_BACKUP,
                                                   szIni);
    SaveAction  = actions[flags & ENV_SAVEACTION];
    AutoMini    = flags & ENV_AUTOMINI;
    AutoRest    = flags & ENV_AUTOREST;
    qsave       = flags & ENV_QUERYSAVE;
    ChgArgs     = flags & ENV_RTARGS;
    fBackup     = flags & ENV_BACKUP;
    fDoCmpDlg   = flags & ENV_CMPDLG;
    TabStops = GetPrivateProfileInt (szDrvr, "TabStops", 4, szIni);

    // Find and Search/Replace options
    //-----------------------------------------------------------------------
    flags = GetPrivateProfileInt (szDrvr, "SearchFlags", 0, szIni);
    fSrchCase   = flags & SRCH_SRCHCASE;
    WholeWord   = flags & SRCH_WHOLEWORD;

    // Recorder options -- the 0x3C is 60 decimal, which is the default
    // string length
    //-----------------------------------------------------------------------
    iRecPause = GetPrivateProfileInt (szRecorder, "Pause", 2000, szIni);
    flags = GetPrivateProfileInt (szRecorder, "Flags", 0x3C00 |
                                                       REC_KEYS |
                                                       REC_CLICKS |
                                                       REC_INCDECL |
                                                       REC_BALANCE,
                                                       szIni);
    iRecInsert  = flags & REC_INSERT;
    fRecKeys    = flags & REC_KEYS;
    fRecClicks  = flags & REC_CLICKS;
    fRecMoves   = flags & REC_MOVES;
    fRecRelWnd  = flags & REC_RELWND;
    fRecIncDecl = flags & REC_INCDECL;
    fRecBalance = flags & REC_BALANCE;
    iRecLen     = HIBYTE (flags);

    // Runtime options
    //-----------------------------------------------------------------------
    flags = GetPrivateProfileInt (szDrvr, "RTFlags", RF_SAVERTA |
#ifdef WIN32
                                                  RF_CDECL |
#endif
                                                  RF_ARRAYCHECK,
                                                  szIni);
    SaveRTA      = flags & RF_SAVERTA;
    ArrayCheck   = flags & RF_ARRAYCHECK;
    PointerCheck = flags & RF_PTRCHECK;
    CdeclCalls   = flags & RF_CDECL;
    ExpDeclare   = flags & RF_EXPDECL;

    GetPrivateProfileString (szDrvr, "Cmd", def, cmdbuf, sizeof (cmdbuf), szIni);
    GetPrivateProfileString (szDrvr, "Tm", def, tmbuf, sizeof (tmbuf), szIni);

    GetPrivateProfileString (szDrvr, "Defc", def, sz, 80, szIni);
    SymCount = min (atoi (sz), 16);
    GetPrivateProfileString (szDrvr, "Defs", def, sz, 320, szIni);
    def = sz;
    while (*def == ' ')
        def++;
    j = 0;
    for (i=0; i<SymCount; i++)
        {
        while ((*def) && (*def != ' '))
            DefSym[i][j++] = *def++;
        DefSym[i][j] = 0;
        def++;
        j = 0;
        }

    // Create the ViewPort window first
    //-----------------------------------------------------------------------
    hwndViewPort = SetupViewport ();

    if (!hwndViewPort)
        return (FALSE);

    if ((VPstate & 3) == 1)
        ShowWindow (hwndViewPort, SW_SHOWMAXIMIZED);
    else if ((VPstate & 3) == 2)
        ShowWindow (hwndViewPort, SW_SHOWMINIMIZED);

    // Parse the command line - if this function returns NULL, then we're
    // done -- no need to continue
    //-----------------------------------------------------------------------
    if (!(hScr = ParseCommandLine (lpCmdLine)))
        {
        DestroyWindow (hwndViewPort);
        return (FALSE);
        }

    // Get the names of the last four files opened and store them in the
    // list
    //-----------------------------------------------------------------------
    iFileCount = GetPrivateProfileInt (szDrvr, "fCount", 0, szIni);
    for (i=0; i<iFileCount; i++)
        {
        CHAR    buf[10];

        wsprintf (buf, "File%d", i+1);
        GetPrivateProfileString (szDrvr, buf, def, sz, 128, szIni);
        pFileOpened[i] = (PSTR)LptrAlloc (lstrlen(sz)+1);
        if (!pFileOpened[i])
            {
            MPError (NULL, MB_OK | MB_ICONSTOP, IDS_OUTOFMEM);
            DestroyWindow (hwndViewPort);
            return (FALSE);
            }
        lstrcpy (pFileOpened[i], sz);
        }

    // Get the base window title
    //-----------------------------------------------------------------------
    LoadString (hInst, IDS_APPNAME, sz, sizeof(sz));

    // Create the frame
    //-----------------------------------------------------------------------
    hwndFrame = CreateWindow (szFrame,
			      sz,
			      WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
                              Frx,
                              Fry,
                              Frw,
                              Frh,
			      NULL,
			      NULL,
			      hInst,
			      NULL);

    if ((!hwndFrame) || (!hwndMDIClient) || (!hwndViewPort))
        return (FALSE);

    // Display the frame window
    //-----------------------------------------------------------------------
    if (nCmdShow != SW_SHOWNORMAL)
        ShowWindow (hwndFrame, nCmdShow);
    else if (FrameState == 1)
        ShowWindow (hwndFrame, SW_SHOWMAXIMIZED);
    else if (FrameState == 2)
        ShowWindow (hwndFrame, SW_SHOWMINIMIZED);
    else
        ShowWindow (hwndFrame, SW_SHOWNORMAL);

    // Show the viewport if we're supposed to (sending it a WM_COMMAND msg
    // with the IDM_WINDOWSHOW parm...
    //-----------------------------------------------------------------------
    if (!(VPstate & 4))
        SendMessage (hwndFrame, WM_COMMAND, IDM_WINDOWSHOW, 0L);

    // Load main menu accelerators
    //-----------------------------------------------------------------------
    if (!(hAccel = LoadAccelerators (hInst, IDMULTIPAD)))
        return (FALSE);

    UpdateWindow (hwndFrame);

    // Load the scripts given on the command line.
    //-----------------------------------------------------------------------
    NextFile = 0;

    for (i=0; hScr[i]; i++)
        {
        CHAR    *scr;

        // If this is the first file and it has nothing in it, we add an
        // untitled script and we're done.
        //-------------------------------------------------------------------
        scr = LocalLock (hScr[i]);
        if ((!i) && (!*scr))
            {
            AddFile (NULL);
            break;
            }

        // Check for an extension -- if not there, append default.  Then,
        // load the file if it isn't already loaded.
        //---------------------------------------------------------------
        EnsureExt (scr, 80);
        if (!AlreadyOpen (scr))
            AddFile (scr);
        LocalUnlock (hScr[i]);
        LocalFree (hScr[i]);
        }

    for (i = 0 ; i < 4 ; i++)
    {
        wsprintf (sz, "wattrec%d", i + 1);
        hBitmap [i] = LoadBitmap (hInst, (LPSTR) sz);
        if (!hBitmap [i])
            return FALSE;
    }


    // We're done.
    //-----------------------------------------------------------------------
    return (TRUE);
}
// 载入INI文件
bool LoadIniFile(m_oConstVarStruct* pConstVar)
{
	ASSERT(pConstVar != NULL);
	CString strSection	= _T("");
	CString strSectionKey = _T("");
	CString strValue = _T("");
	CString strFilePath	= _T("");
	wchar_t strBuff[INIFileStrBufSize];
	strFilePath = pConstVar->m_strINIFilePath.c_str();
	if (false == IfFileExist(strFilePath))
	{
		strFilePath += _T("is not exist!");
		AfxMessageBox(strFilePath);
		return false;
	}
	try
	{
		//读取ini文件中相应字段的内容
		strSection = _T("常量设置");					// 获取当前区域

		strSectionKey=_T("InstrumentCountAll");			// 仪器设备个数
		pConstVar->m_iInstrumentNum = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

		strSectionKey=_T("SEGDDataBufCountAll");		// SEGD数据缓冲区个数
		pConstVar->m_iSEGDDataBufCountAll = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

		strSectionKey=_T("SEGDDataBufSize");			// SEGD数据缓冲区大小
		pConstVar->m_iSEGDDataBufSize = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

		strSectionKey=_T("SEGDCheckFinishTime");		// 判断SEGD数据存储完成的时间
		pConstVar->m_iSEGDCheckFinishTime = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

		strSectionKey=_T("OptTaskCountAll");			// 施工任务个数
		pConstVar->m_iOptTaskCountAll = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

		strSectionKey=_T("OneSleepTime");				// 一次休眠的时间
		pConstVar->m_iOneSleepTime = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

		strSectionKey=_T("LogOutPutSleepTimes");		// 日志输出线程写日志的延时次数
		pConstVar->m_iLogOutPutSleepTimes = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

		strSectionKey=_T("HertBeatSleepTimes");			// 心跳线程发送心跳帧延时次数
		pConstVar->m_iHeartBeatSleepTimes = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

		strSectionKey=_T("HeadFrameSleepTimes");		// 首包线程接收首包延时次数
		pConstVar->m_iHeadFrameSleepTimes = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

		strSectionKey=_T("IPSetFrameSleepTimes");		// IP地址设置线程延时次数
		pConstVar->m_iIPSetFrameSleepTimes = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

		strSectionKey=_T("TailFrameSleepTimes");		// 尾包线程延时次数
		pConstVar->m_iTailFrameSleepTimes = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

		strSectionKey=_T("MonitorSleepTimes");		// 路由监视线程延时次数
		pConstVar->m_iMonitorSleepTimes = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

		strSectionKey=_T("TimeDelaySleepTimes");		// 时统设置线程延时次数
		pConstVar->m_iTimeDelaySleepTimes = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

		strSectionKey=_T("ADCSetSleepTimes");			// ADC参数设置线程延时次数
		pConstVar->m_iADCSetSleepTimes = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

		strSectionKey=_T("ErrorCodeSleepTimes");		// 误码查询线程延时次数
		pConstVar->m_iErrorCodeSleepTimes = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

		strSectionKey=_T("ADCDataRecSleepTimes");		// ADC数据接收线程延时次数
		pConstVar->m_iADCDataRecSleepTimes = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

		strSectionKey=_T("ADCDataSaveSleepTimes");		// ADC数据存储线程延时次数
		pConstVar->m_iADCDataSaveSleepTimes = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

		strSectionKey=_T("CloseThreadSleepTimes");		// 等待线程关闭的延时次数
		pConstVar->m_iCloseThreadSleepTimes = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

		strSectionKey=_T("TimeDelayFDUToFDU");			// 采集站之间需要时统修正的值
		pConstVar->m_iTimeDelayFDUToFDU = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

		strSectionKey=_T("TimeDelayLCIToFDU");			// LCI到采集站之间需要时统修正的值
		pConstVar->m_iTimeDelayLCIToFDU = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

		strSectionKey=_T("TimeDelayFDUToLAUL");			// 采集站到电源站需要时统修正的值
		pConstVar->m_iTimeDelayFDUToLAUL = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

		strSectionKey=_T("TimeDelayLAULToFDU");			// 电源站到采集站需要时统修正的值
		pConstVar->m_iTimeDelayLAULToFDU = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

		strSectionKey=_T("HeadFrameStableNum");			// 首包稳定计数
		pConstVar->m_iHeadFrameStableTimes = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

		strSectionKey=_T("IPAddrResetTimes");		// IP地址重设次数
		pConstVar->m_iIPAddrResetTimes = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

		strSectionKey=_T("TailFrameStableTimes");		// 尾包稳定计数
		pConstVar->m_iTailFrameStableTimes = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

		strSectionKey=_T("MonitorStableTime");		// 路由监视稳定时间
		pConstVar->m_iMonitorStableTime = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

		strSectionKey=_T("LineSysStableTime");		// 测网系统达到稳定状态时间
		pConstVar->m_iLineSysStableTime = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

// 		strSectionKey=_T("ADCSetOptNb");			// ADC参数设置操作序号
// 		pConstVar->m_iADCSetOptNb = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

// 		strSectionKey=_T("ADCStartSampleOptNb");	// ADC开始采集操作序号
// 		pConstVar->m_iADCStartSampleOptNb = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

// 		strSectionKey=_T("ADCStopSampleOptNb");		// ADC停止采集操作序号
// 		pConstVar->m_iADCStopSampleOptNb = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

		strSectionKey=_T("ADCSetCmdNum");			// ADC参数设置命令数
		pConstVar->m_iADCSetCmdNum = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

		strSectionKey=_T("ADCSetCmdBeginNb");		// ADC参数设置起始命令序号
		pConstVar->m_iADCSetCmdBeginNb = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

		strSectionKey=_T("ADCStartSampleCmdNum");	// ADC开始采集命令数
		pConstVar->m_iADCStartSampleCmdNum = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

		strSectionKey=_T("ADCStartSampleBeginNb");	// ADC开始采集起始命令序号
		pConstVar->m_iADCStartSampleBeginNb = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

		strSectionKey=_T("ADCStopSampleCmdNum");	// ADC停止采集命令数
		pConstVar->m_iADCStopSampleCmdNum = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

		strSectionKey=_T("ADCStopSampleBeginNb");	// ADC停止采集起始命令序号
		pConstVar->m_iADCStopSampleBeginNb = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

// 		strSectionKey=_T("InstrumentTypeLAUX");		// 仪器类型-交叉站
// 		pConstVar->m_iInstrumentTypeLAUX = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

// 		strSectionKey=_T("InstrumentTypeLAUL");		// 仪器类型-电源站
// 		pConstVar->m_iInstrumentTypeLAUL = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

// 		strSectionKey=_T("InstrumentTypeFDU");		// 仪器类型-采集站
// 		pConstVar->m_iInstrumentTypeFDU = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

// 		strSectionKey=_T("InstrumentTypeLCI");		// 仪器类型-LCI
// 		pConstVar->m_iInstrumentTypeLCI= GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

// 		strSectionKey=_T("DirectionTop");			// 方向上方
// 		pConstVar->m_iDirectionTop = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

// 		strSectionKey=_T("DirectionDown");			// 方向下方
// 		pConstVar->m_iDirectionDown = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

// 		strSectionKey=_T("DirectionLeft");			// 方向左方
// 		pConstVar->m_iDirectionLeft = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);
// 
// 		strSectionKey=_T("DirectionRight");			// 方向右方
// 		pConstVar->m_iDirectionRight = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);
// 
// 		strSectionKey=_T("DirectionCenter");		// 方向正中
// 		pConstVar->m_iDirectionCenter = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

		strSectionKey=_T("IPSetAddrStart");			// IP地址设置的起始地址
		pConstVar->m_iIPSetAddrStart = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

		strSectionKey=_T("IPSetAddrInterval");		// IP地址设置的间隔
		pConstVar->m_iIPSetAddrInterval = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

		strSectionKey=_T("RoutSetAddrStart");		// 路由地址设置的起始地址
		pConstVar->m_iRoutSetAddrStart = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

		strSectionKey=_T("RoutSetAddrInterval");	// 路由地址设置的间隔
		pConstVar->m_iRoutSetAddrInterval = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

		strSectionKey=_T("BroadcastPortStart");		// 设置广播端口起始地址
		pConstVar->m_iBroadcastPortStart = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

		strSectionKey=_T("IPBroadcastAddr");		// 设置为广播IP
		pConstVar->m_uiIPBroadcastAddr = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

// 		strSectionKey=_T("ADCFrameSaveInOneFileNum");	// 一个文件内存储单个设备ADC数据帧数
// 		pConstVar->m_iADCFrameSaveInOneFileNum = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

		strSectionKey=_T("ADCSaveHeadLineNum");		// 存储ADC数据的文件头行数
		pConstVar->m_iADCSaveHeadLineNum = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

		strSectionKey=_T("ADCSaveLeftInfoBytes");		// 存储ADC数据的左侧预留信息字节数
		pConstVar->m_iADCSaveLeftInfoBytes = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

		strSectionKey=_T("ADCSaveDataBytes");		// 存储ADC数据的字节数
		pConstVar->m_iADCSaveDataBytes = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

		strSectionKey=_T("ADCSaveDataIntervalBytes");		// 存储ADC数据之间的间隔字节数
		pConstVar->m_iADCSaveDataIntervalBytes = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

		strSectionKey=_T("ADCDataBufSize");		// 设备ADC数据缓冲区大小
		pConstVar->m_iADCDataBufSize = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

		strSectionKey=_T("SaveTestDataNum");			// 存储用于测试计算的数据个数
		pConstVar->m_uiSaveTestDataNum = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

		strSectionKey=_T("TBSleepTimeHigh");			// TB设置延时高位
		pConstVar->m_uiTBSleepTimeHigh = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

		strSectionKey=_T("TBSleepTimeLow");				// TB设置延时低位
		pConstVar->m_usTBSleepTimeLow = static_cast<unsigned short>(GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath));

		strSectionKey=_T("FieldOnWaitTimeLimit");		// FieldOn与上一次FieldOff的时间间隔
		pConstVar->m_uiFieldOnWaitTimeLimit = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

		//读取ini文件中相应字段的内容
		strSection = _T("帧格式设置");			// 获取当前区域
		strSectionKey=_T("FrameHeadSize");		// 帧头长度
		pConstVar->m_iFrameHeadSize = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

		strSectionKey=_T("FrameHeadCheck");		// 同步帧头
		GetPrivateProfileString(strSection,strSectionKey,NULL,strBuff,sizeof(strBuff) / 2,strFilePath);
		strValue = strBuff;
		ParseCStringToArray(&pConstVar->m_cpFrameHeadCheck, pConstVar->m_iFrameHeadSize, strValue);

		strSectionKey=_T("FrameCmdSize1B");		// 命令字长度1字节
		pConstVar->m_iFrameCmdSize1B = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

		strSectionKey=_T("FramePacketSize1B");	// 命令包长度1字节
		pConstVar->m_iFramePacketSize1B = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

		strSectionKey=_T("FramePacketSize2B");	// 命令包长度2字节
		pConstVar->m_iFramePacketSize2B = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

		strSectionKey=_T("FramePacketSize4B");	// 命令包长度4字节
		pConstVar->m_iFramePacketSize4B = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

		strSectionKey=_T("ADCDataSize3B");		// ADC数据所占字节数
		pConstVar->m_iADCDataSize3B = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

		strSectionKey=_T("ADCDataInOneFrameNum");	// 一帧内ADC数据个数
		pConstVar->m_iADCDataInOneFrameNum = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

		strSectionKey=_T("ADCFramePointLimit");	// ADC数据帧指针偏移量上限
		pConstVar->m_usADCFramePointLimit = static_cast<unsigned short>(GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath));

		strSectionKey=_T("CommandWordMaxNum");	// 命令字个数最大值
		pConstVar->m_iCommandWordMaxNum = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);
		pConstVar->m_iADCSetCommandMaxByte = pConstVar->m_iCommandWordMaxNum 
			* pConstVar->m_iFramePacketSize4B;

		strSectionKey=_T("SndFrameBufInit");	// 发送帧缓冲区初值设定
		pConstVar->m_cSndFrameBufInit = static_cast<char>(GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath));

		strSectionKey=_T("RcvFrameSize");		// 接收的网络数据帧帧长度
		pConstVar->m_iRcvFrameSize = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

		strSectionKey=_T("SndFrameSize");		// 发送的网络数据帧帧长度
		pConstVar->m_iSndFrameSize = GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath);

		/////////////////////////////////////////////////////////////////////////
		strSection = _T("服务器与设备命令字设置");		// 获取当前区域
		strSectionKey=_T("SendSetCmd");			// 发送设置命令
		pConstVar->m_usSendSetCmd = static_cast<unsigned short>(GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath));

		strSectionKey=_T("SendQueryCmd");		// 发送查询命令
		pConstVar->m_usSendQueryCmd = static_cast<unsigned short>(GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath));

		strSectionKey=_T("SendADCCmd");			// 发送ADC采样数据重发命令
		pConstVar->m_usSendADCCmd = static_cast<unsigned short>(GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath));

		strSectionKey=_T("CmdSn");				// 串号
		pConstVar->m_byCmdSn = static_cast<BYTE>(GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath));

		strSectionKey=_T("CmdHeadFrameTime");	// 首包时间
		pConstVar->m_byCmdHeadFrameTime = static_cast<BYTE>(GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath));

		strSectionKey=_T("CmdLocalIPAddr");		// 本地IP地址
		pConstVar->m_byCmdLocalIPAddr = static_cast<BYTE>(GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath));

		strSectionKey=_T("CmdLocalSysTime1");	// 本地系统时间
		pConstVar->m_byCmdLocalSysTime1 = static_cast<BYTE>(GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath));

		strSectionKey=_T("CmdLocalSysTime2");	// 本地系统时间
		pConstVar->m_byCmdLocalSysTime2 = static_cast<BYTE>(GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath));

		strSectionKey=_T("CmdLocalSysTime3");	// 本地系统时间
		pConstVar->m_byCmdLocalSysTime3 = static_cast<BYTE>(GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath));

		strSectionKey=_T("CmdLocalTimeFixedHigh");	// 本地时间修正高位
		pConstVar->m_byCmdLocalTimeFixedHigh = static_cast<BYTE>(GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath));

		strSectionKey=_T("CmdLocalTimeFixedLow");	// 本地时间修正低位
		pConstVar->m_byCmdLocalTimeFixedLow = static_cast<BYTE>(GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath));

		strSectionKey=_T("CmdADCDataReturnAddr");	// 自动数据返回地址
		pConstVar->m_byCmdADCDataReturnAddr = static_cast<BYTE>(GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath));

		strSectionKey=_T("CmdADCDataReturnPort");	// 自动数据返回端口和命令
		pConstVar->m_byCmdADCDataReturnPort = static_cast<BYTE>(GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath));

		strSectionKey=_T("CmdADCDataReturnPortLimit");	// 端口递增下限和上限
		pConstVar->m_byCmdADCDataReturnPortLimit = static_cast<BYTE>(GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath));

		strSectionKey=_T("CmdSetBroadCastPort");	// 设置网络等待端口和命令
		pConstVar->m_byCmdBroadCastPortSet = static_cast<BYTE>(GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath));

		strSectionKey=_T("CmdFDUErrorCode");		// 系统硬件状态拷贝
		pConstVar->m_byCmdFDUErrorCode = static_cast<BYTE>(GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath));

		strSectionKey=_T("CmdTBHigh");				// TB时刻高位
		pConstVar->m_byCmdTBHigh = static_cast<BYTE>(GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath));

		strSectionKey=_T("CmdTbLow");				// TB时刻低位
		pConstVar->m_byCmdTbLow = static_cast<BYTE>(GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath));

		strSectionKey=_T("CmdLAUXRoutOpenQuery");	// work_ctrl 交叉站方向
		pConstVar->m_byCmdLAUXRoutOpenQuery = static_cast<BYTE>(GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath));

		strSectionKey=_T("CmdLAUXRoutOpenSet");		// 路由开关
		pConstVar->m_byCmdLAUXRoutOpenSet = static_cast<BYTE>(GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath));

		strSectionKey=_T("CmdVersion");				// 仪器软件版本
		pConstVar->m_byCmdVersion = static_cast<BYTE>(GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath));

		strSectionKey=_T("CmdTailRecSndTimeLow1");	// 尾包接收\发送时刻低位
		pConstVar->m_byCmdTailRecSndTime1 = static_cast<BYTE>(GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath));
		strSectionKey=_T("CmdTailRecSndTimeLow2");	// 尾包接收\发送时刻低位
		pConstVar->m_byCmdTailRecSndTime2 = static_cast<BYTE>(GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath));
 		strSectionKey=_T("CmdTailRecSndTimeLow3");	// 尾包接收\发送时刻低位
 		pConstVar->m_byCmdTailRecSndTime3 = static_cast<BYTE>(GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath));

		strSectionKey=_T("CmdBroadCastPortSet");	// 广播命令等待端口匹配
		pConstVar->m_byCmdBroadCastPortSeted = static_cast<BYTE>(GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath));

		strSectionKey=_T("CmdADCSet");				// 设置ADC控制命令命令字
		pConstVar->m_byCmdADCSet = static_cast<char>(GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath));

		strSectionKey=_T("CmdNetTime");				// 网络时刻
		pConstVar->m_byCmdNetTime = static_cast<BYTE>(GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath));

		strSectionKey=_T("CmdLineTailRecTimeLAUX");	// 交叉站大线尾包接收时刻
		pConstVar->m_byCmdLineTailRecTimeLAUX = static_cast<BYTE>(GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath));

		strSectionKey=_T("CmdLAUTailRecTimeLAUX");	// 交叉站交叉线尾包接收时刻
		pConstVar->m_byCmdLAUTailRecTimeLAUX = static_cast<BYTE>(GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath));

		strSectionKey=_T("CmdLAUXErrorCode1");		// 交叉站故障1
		pConstVar->m_byCmdLAUXErrorCode1 = static_cast<BYTE>(GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath));

		strSectionKey=_T("CmdLAUXErrorCode2");		// 交叉站故障2
		pConstVar->m_byCmdLAUXErrorCode2 = static_cast<BYTE>(GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath));

		strSectionKey=_T("CmdLAUXSetRout");			// 交叉站路由分配
		pConstVar->m_byCmdLAUXSetRout = static_cast<BYTE>(GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath));

		strSectionKey=_T("CmdReturnRout");			// 返回路由
		pConstVar->m_byCmdReturnRout = static_cast<BYTE>(GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath));

		strSectionKey=_T("CmdEnd");					// 命令解析结束命令
		pConstVar->m_byCmdEnd = static_cast<BYTE>(GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath));

		strSectionKey=_T("CmdTBCtrlStartSample");		// TB开关控制ADC数据采集命令
		pConstVar->m_usCmdTBCtrlStartSample = static_cast<unsigned short>(GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath));

		strSectionKey=_T("CmdTBLoseCtrlStartSample");	// 无需TB开关控制ADC数据采集命令
		pConstVar->m_usCmdTBLoseCtrlStartSample = static_cast<unsigned short>(GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath));

		strSectionKey=_T("CmdTBCtrlStopSample");		// TB开关控制ADC数据停止采集命令
		pConstVar->m_usCmdTBCtrlStopSample = static_cast<unsigned short>(GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath));

		strSectionKey=_T("CmdCtrlCloseLed");			// LED灯灭
		pConstVar->m_usCmdCtrlCloseLed = static_cast<unsigned short>(GetPrivateProfileInt(strSection,strSectionKey,NULL,strFilePath));
	}
	catch (CMemoryException* e)
	{
		// 加入错误消息
		e->ReportError(MB_OK, IDS_ERR_MEMORY_EXCEPTION);
	}
	catch (CFileException* e)
	{
		e->ReportError(MB_OK, IDS_ERR_FILE_EXCEPTION);
	}
	catch (CException* e)
	{
		e->ReportError(MB_OK, IDS_ERR_OTHER_EXCEPTION);
	}
	return true;
}