Beispiel #1
0
static VOID
SetDefaultLayout()
{
    HKL hKl;
    TCHAR szLCID[CCH_LAYOUT_ID + 1], szLayoutNum[CCH_ULONG_DEC + 1];
    LVITEM item;
    INT LayoutNum;

    if (IsLayoutSelected() != -1)
    {
        ZeroMemory(&item, sizeof(LVITEM));

        item.mask = LVIF_PARAM;
        item.iItem = IsLayoutSelected();

        (VOID) ListView_GetItem(GetDlgItem(MainDlgWnd, IDC_KEYLAYOUT_LIST), &item);

        LayoutNum = (INT) item.lParam;
        _ultot(LayoutNum, szLayoutNum, 10);

        if (GetLayoutID(szLayoutNum, szLCID))
        {
            hKl = LoadKeyboardLayout(szLCID, KLF_ACTIVATE);
            SystemParametersInfo(SPI_SETDEFAULTINPUTLANG, 0, &hKl, SPIF_SENDWININICHANGE);
        }
    }
}
Beispiel #2
0
void CIni::WriteWORD(LPCTSTR strEntry,WORD n, LPCTSTR strSection/* = NULL*/)
{
	if(strSection != NULL) 
		m_strSection = strSection;
	TCHAR strBuffer[MAX_PATH];
	_ultot(n, strBuffer, 10);
	WritePrivateProfileString(m_strSection,strEntry,strBuffer,m_strFileName);
}
Beispiel #3
0
static VOID
InitInputLangPropDlg(HWND hDlg)
{
    HKEY hKey, hSubKey;
    LVITEM item;
    INT LayoutNum;
    TCHAR szLayoutNum[10 + 1], szPreload[CCH_LAYOUT_ID + 1],
          szTmp[CCH_LAYOUT_ID + 1], szName[MAX_PATH];
    DWORD dwSize;
    LANGID langid;

    ZeroMemory(&item, sizeof(LVITEM));

    item.mask = LVIF_PARAM;
    item.iItem = IsLayoutSelected();

    (VOID) ListView_GetItem(GetDlgItem(MainDlgWnd, IDC_KEYLAYOUT_LIST), &item);
    LayoutNum = (INT) item.lParam;
    OldLayoutNum = LayoutNum;

    if (RegOpenKeyEx(HKEY_CURRENT_USER, _T("Keyboard Layout\\Preload"), 0,
                     KEY_ALL_ACCESS, &hKey) == ERROR_SUCCESS)
    {
        _ultot(LayoutNum, szLayoutNum, 10);

        dwSize = sizeof(szPreload);
        RegQueryValueEx(hKey, szLayoutNum, NULL, NULL, (LPBYTE)szPreload, &dwSize);

        langid = (LANGID)_tcstoul(szPreload, NULL, 16);
        GetLocaleInfo(langid, LOCALE_SLANGUAGE, (LPTSTR)szName, sizeof(szName) / sizeof(TCHAR));
        SetWindowText(GetDlgItem(hDlg, IDC_INPUT_LANG_STR), szName);

        if (szPreload[0] == 'd')
        {
            if (RegOpenKeyEx(HKEY_CURRENT_USER, _T("Keyboard Layout\\Substitutes"), 0,
                                     KEY_ALL_ACCESS, &hSubKey) == ERROR_SUCCESS)
            {
                if (RegQueryValueEx(hSubKey, szPreload, NULL, NULL, (LPBYTE)szTmp, &dwSize) != ERROR_SUCCESS)
                {
                    RegCloseKey(hSubKey);
                    RegCloseKey(hKey);
                    return;
                }
                lstrcpy(szPreload, szTmp);
                RegCloseKey(hSubKey);
            }
        }

        if (GetLayoutName(szPreload, szName))
        {
            SendMessage(GetDlgItem(hDlg, IDC_KB_LAYOUT_IME_COMBO),
                        CB_SELECTSTRING, (WPARAM)-1, (LPARAM)szName);
        }
    }
    RegCloseKey(hKey);
}
CHotKeysToCmdRouter::CHotKeysToCmdRouter()
: mp_OriginalWnd(NULL)
{
 DWORD id = GetCurrentThreadId();
 TCHAR string[256];
 _ultot(id, string, 16);
 m_thread_id_string = string;

 HotKeysManager::GetInstance()->_AddRouter(this);
}
Beispiel #5
0
void Dlg_CreateReport (HWND hwndEdit) {
   TCHAR szBuf[500];    // Line buffer
   int   i, nVisLine;
   DWORD dwMin, dwMax;
   float rAvg, rStdDev;

   // Disable updates to prevent the edit box from scrolling.
   SetWindowRedraw(hwndEdit, FALSE);

   Dlg_IntervalStat(g_pdwTickSamples, g_nSamplesMax, &dwMin,
      &dwMax, &rAvg, &rStdDev);

   // Clear the report.
   Edit_SetText(hwndEdit, _TEXT(""));

   // Write the report.
   _stprintf(szBuf, 
      _TEXT("Period (mS):  %lu\r\n")
      _TEXT("Sample Size:  %lu\r\n")
      _TEXT("\r\n")
      _TEXT("Interval Statistics\r\n")
      _TEXT("   Avg. Period:  %.3f\r\n")
      _TEXT("   Min. Period:  %lu\r\n")
      _TEXT("   Max. Period:  %lu\r\n")
      _TEXT("   Standard Dev.:  %.3f\r\n")
      _TEXT("\r\n")
      _TEXT("Timer Samples:"),
      g_uPeriod,
      g_nSamplesMax,
      rAvg,
      dwMin,
      dwMax,
      (double) rStdDev);

   Dlg_AppendEditText(hwndEdit, szBuf);
   
   _tcscpy(szBuf, _TEXT("\r\n"));
   for (i = 0; i < g_nSamplesMax; i++) {
      _ultot(g_pdwTickSamples[i], szBuf + 2, 10);
      Dlg_AppendEditText(hwndEdit, szBuf);
   }

   // Move caret to start of text.
   Edit_SetSel(hwndEdit, 0, 0);

   // Make first report line first visible line.
   nVisLine = Edit_GetFirstVisibleLine(hwndEdit);
   Edit_Scroll(hwndEdit, -nVisLine, 0);

   // Enable updates, and force update.
   SetWindowRedraw(hwndEdit, TRUE);
   InvalidateRect(hwndEdit, NULL, TRUE);
}
Beispiel #6
0
LPTSTR Variant2T(VARIANT var,LPTSTR buf)
{
	USES_CONVERSION;
	if (var.vt == VT_BYREF+VT_VARIANT)
		var = *var.pvarVal;
	if (var.vt == VT_ERROR)
		return _T("");
	else if (var.vt==VT_BSTR)
		return OLE2T(var.bstrVal);
	else if (var.vt==VT_I2 || var.vt==VT_I4 || var.vt==VT_I8)
#ifdef _WIN64
		return _ui64tot(var.uintVal,buf,10);
#else
		return _ultot(var.uintVal,buf,10);
#endif
	return _T("");
}
Beispiel #7
0
bool CHelpDB::ElementToStruct(CHelpMessage& info, MSXML::IXMLDOMElementPtr& El, bool bIncUsage)
{
    bool r = false;

    try
    {
        _variant_t vAlias = El->getAttribute(TAG_ALIAS);
        _variant_t vCreator = El->getAttribute(TAG_CREATOR);
        _variant_t vText = El->getAttribute(TAG_TEXT);
        _variant_t vCreated = El->getAttribute(TAG_TIME);
        _variant_t vUsage = El->getAttribute(TAG_USAGE);

        HW2T(info.Alias, vAlias.bstrVal);
        HW2T(info.Creator, vCreator.bstrVal);
        HW2T(info.Text, vText.bstrVal);

        TSTRING sTemp;

        HW2T(sTemp, vCreated.bstrVal);
        Str2Bin(sTemp, (PBYTE)&info.Created, sizeof(info.Created));

        HW2T(sTemp, vUsage.bstrVal);
        info.nUsage = _tcstoul(sTemp.c_str(), 0, 10);

        if(bIncUsage)
        {
            TCHAR tsz[500];
            info.nUsage++;
            _ultot(info.nUsage, tsz, 10);
            El->setAttribute(_bstr_t(TAG_USAGE), _variant_t(tsz));
        }

        r = true;
    }
    catch(_com_error& e)
    {
        sprintf(m_err, _T("COM Error: %08x"), e.Error(), (TCHAR*)e.Description());
        g_pLog->msg(_T("CHelpDB::ElementToStruct ERROR"));
    }

    return r;
}
static LPCTSTR GetDriveSizeAsString(LPCTSTR pszRootDir)
{
    _ASSERTE(pszRootDir != 0);

    ULARGE_INTEGER liDummy;
    ULARGE_INTEGER liSize;
    static TCHAR szSize[64];

    *szSize = 0;

    // Get partition size in bytes	
    if (GetDiskFreeSpaceEx(pszRootDir, &liDummy, &liSize, &liDummy)) {
	// Covert to megabytes
	ULONG nSize = (ULONG)(liSize.QuadPart / (1024 * 1024));
	// Convert to a string
	_ultot(nSize, szSize, 10);
	lstrcat(szSize, TEXT(" MB"));
    }

    return szSize;
}	
Beispiel #9
0
TCString DBGetContactSettingAsString(MCONTACT hContact, const char *szModule, const char *szSetting, const TCHAR *szDefaultValue)
{   // also converts numeric values to a string
    DBVARIANT dbv = {0};
    int iRes = db_get_ws(hContact, szModule, szSetting, &dbv);

    TCString Result;
    if (!iRes && (dbv.type == DBVT_ASCIIZ || dbv.type == DBVT_WCHAR))
    {
        Result = dbv.ptszVal;
    }
    else if (dbv.type == DBVT_BYTE || dbv.type == DBVT_WORD || dbv.type == DBVT_DWORD)
    {
        long value = (dbv.type == DBVT_DWORD) ? dbv.dVal : (dbv.type == DBVT_WORD ? dbv.wVal : dbv.bVal);
        _ultot(value, Result.GetBuffer(64), 10);
        Result.ReleaseBuffer();
    }
    else Result = szDefaultValue;

    if (!iRes)
        db_free(&dbv);

    return Result;
}
Beispiel #10
0
static VOID
AddNewLayout(HWND hwndDlg)
{
    TCHAR NewLayout[CCH_ULONG_DEC + 1], Lang[MAX_PATH],
          LangID[CCH_LAYOUT_ID + 1], Layout[MAX_PATH],
          SubPath[CCH_LAYOUT_ID + 1], szMessage[MAX_PATH];
    INT iLayout, iLang;
    HKEY hKey, hSubKey;
    DWORD cValues;
    PTSTR pts;
    LCID lcid;

    iLayout = SendMessage(hLayoutList, CB_GETCURSEL, 0, 0);
    if (iLayout == CB_ERR) return;

    if (RegOpenKeyEx(HKEY_CURRENT_USER, _T("Keyboard Layout\\Preload"), 0, KEY_ALL_ACCESS, &hKey) == ERROR_SUCCESS)
    {
        if (RegQueryInfoKey(hKey, NULL, NULL, NULL, NULL, NULL, NULL, &cValues, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
        {
            _ultot(cValues + 1, NewLayout, 10);

            iLang = SendMessage(hLangList, CB_GETCURSEL, 0, 0);
            lcid = SendMessage(hLangList, CB_GETITEMDATA, iLang, 0);
            pts = (PTSTR) SendMessage(hLayoutList, CB_GETITEMDATA, iLayout, 0);

            GetLocaleInfo(MAKELCID(lcid, SORT_DEFAULT), LOCALE_ILANGUAGE, Lang, sizeof(Lang) / sizeof(TCHAR));
            wsprintf(LangID, _T("0000%s"), Lang);

            if (IsLayoutExists(pts, LangID))
            {
                LoadString(hApplet, IDS_LAYOUT_EXISTS2, szMessage, sizeof(szMessage) / sizeof(TCHAR));
                MessageBox(hwndDlg, szMessage, NULL, MB_OK | MB_ICONINFORMATION);

                RegCloseKey(hKey);
                return;
            }

            if (_tcscmp(LangID, pts) != 0)
            {
                if (!GetLayoutName(pts, Layout))
                {
                    RegCloseKey(hKey);
                    return;
                }
            }
            else
            {
                if (!GetLayoutName(LangID, Layout))
                {
                    RegCloseKey(hKey);
                    return;
                }
            }

            if (SendMessage(hLayoutList, CB_SELECTSTRING, (WPARAM) -1, (LPARAM)Layout) != CB_ERR)
            {
                if (GetLayoutCount(Lang) >= 1)
                {
                    wsprintf(SubPath, _T("d%03d%s"), GetLayoutCount(Lang), Lang);
                }
                else if ((_tcscmp(LangID, pts) != 0) && (GetLayoutCount(Lang) == 0))
                {
                    wsprintf(SubPath, _T("d%03d%s"), 0, Lang);
                }
                else SubPath[0] = '\0';
            }
            else
            {
                RegCloseKey(hKey);
                return;
            }

            if (_tcslen(SubPath) != 0)
            {
                if (RegCreateKeyEx(HKEY_CURRENT_USER, _T("Keyboard Layout\\Substitutes"), 0, NULL,
                                   REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,
                                   NULL, &hSubKey, NULL) == ERROR_SUCCESS)
                {
                    if (RegSetValueEx(hSubKey, SubPath, 0, REG_SZ, (LPBYTE)pts,
                                      (DWORD)((CCH_LAYOUT_ID + 1) * sizeof(TCHAR))) != ERROR_SUCCESS)
                    {
                        RegCloseKey(hSubKey);
                        RegCloseKey(hKey);
                        return;
                    }
                    RegCloseKey(hSubKey);
                }
                lstrcpy(pts, SubPath);
            }

            if (RegSetValueEx(hKey,
                              NewLayout,
                              0,
                              REG_SZ,
                              (LPBYTE)pts,
                              (DWORD)((CCH_LAYOUT_ID + 1) * sizeof(TCHAR))) == ERROR_SUCCESS)
            {
                UpdateLayoutsList();
            }
        }
        RegCloseKey(hKey);
    }
}
FC_TOAPI LONG FC_TODECL FC_RegGetStrByPath(
    const TCHAR*   pszPath, 
    long           flags,
    TCHAR          szVal[/*nBuff*/],
    size_t         nBuff  
)
{
    HKEY         hKey;
    LONG         lret;
    LONG         lret2;
    HKEY         hkeySub;
    const TCHAR* pszValName;
    TCHAR        szSubKey[2*MAX_PATH];
    DWORD        dwType;
    DWORD        cbData;

    if(nBuff==0)
        lret = ERROR_BUFFER_OVERFLOW;

    szVal[0] = 0;

    hKey = FC_RegHYKYFromPath(pszPath, &pszValName);
    if(!hKey)
        return ERROR_PATH_NOT_FOUND;

    if(!FC_StringCopyToBuffer(szSubKey, FC_ARRAY_LEN(szSubKey), pszValName))
        return ERROR_BUFFER_OVERFLOW;

    pszValName = FC_StringGetFilePart(pszPath);
    FC_StringCutFilePart(szSubKey);

    lret = RegOpenKeyEx(hKey, szSubKey, 0, KEY_READ, &hkeySub);

    if(lret==ERROR_SUCCESS) 
    {
        //check the data type:
        cbData = nBuff*sizeof(TCHAR);
        lret = RegQueryValueEx(
          hkeySub,        // handle to key
          pszValName,     // value name
          NULL,           // reserved
          &dwType,        // type buffer
          (LPBYTE)szVal,  // data buffer
          &cbData         // size of data buffer
        );

        if(lret==ERROR_SUCCESS)
        {
            if(dwType==REG_SZ || dwType==REG_EXPAND_SZ)
            {
                ;
            }
            else if(dwType==REG_DWORD)
            {
                szSubKey[0] = '0';
                szSubKey[1] = 'x';
                _ultot(*(DWORD*)szVal, szSubKey+2, 16);
                if(!FC_StringCopyToBuffer(szVal, nBuff, szSubKey))
                    lret = ERROR_MORE_DATA;
            }
            else
            {
                lret = ERROR_INVALID_DATA;//TODO
            }
        }
    }

    if(hkeySub)
    {
        lret2 = RegCloseKey(hkeySub);
        if(lret==ERROR_SUCCESS)
            lret = lret2;
    }
    return lret;
}
Beispiel #12
0
static VOID
SaveInputLang(HWND hDlg)
{
    HKEY hKey, hSubKey;
    TCHAR szLayoutID[CCH_LAYOUT_ID + 1], szLayoutNum[CCH_ULONG_DEC + 1],
          szPreload[CCH_LAYOUT_ID + 1], LangID[CCH_LAYOUT_ID + 1], szMessage[MAX_PATH],
          Lang[MAX_PATH], SubPath[MAX_PATH];
    PTSTR pts;
    INT iLayout;
    DWORD dwSize;
    LANGID langid;

    iLayout = SendMessage(GetDlgItem(hDlg, IDC_KB_LAYOUT_IME_COMBO), CB_GETCURSEL, 0, 0);
    if (iLayout == CB_ERR) return;

    pts = (PTSTR) SendMessage(GetDlgItem(hDlg, IDC_KB_LAYOUT_IME_COMBO), CB_GETITEMDATA, iLayout, 0);

    _ultot(OldLayoutNum, szLayoutNum, 10);
    if (!GetLayoutID(szLayoutNum, szLayoutID)) return;

    // if old layout = selected layout
    if (_tcscmp(szLayoutID, pts) == 0) return;

    if (RegOpenKeyEx(HKEY_CURRENT_USER, _T("Keyboard Layout\\Preload"), 0,
                     KEY_ALL_ACCESS, &hKey) == ERROR_SUCCESS)
    {
        dwSize = sizeof(szPreload);
        if (RegQueryValueEx(hKey, szLayoutNum, NULL, NULL, (LPBYTE)szPreload, &dwSize) != ERROR_SUCCESS)
        {
            RegCloseKey(hKey);
            return;
        }

        langid = (LANGID)_tcstoul(szPreload, NULL, 16);
        GetLocaleInfo(langid, LOCALE_ILANGUAGE, Lang, sizeof(Lang) / sizeof(TCHAR));
        wsprintf(LangID, _T("0000%s"), Lang);

        if (IsLayoutExists(pts, LangID))
        {
            LoadString(hApplet, IDS_LAYOUT_EXISTS, szMessage, sizeof(szMessage) / sizeof(TCHAR));
            MessageBox(hDlg, szMessage, NULL, MB_OK | MB_ICONINFORMATION);

            RegCloseKey(hKey);
            return;
        }

        if (szPreload[0] == 'd')
        {
            if (_tcscmp(LangID, pts) == 0)
            {
                if (RegOpenKeyEx(HKEY_CURRENT_USER, _T("Keyboard Layout\\Substitutes"), 0,
                                 KEY_ALL_ACCESS, &hSubKey) == ERROR_SUCCESS)
                {
                    if (RegDeleteValue(hSubKey, szPreload) != ERROR_SUCCESS)
                    {
                        RegCloseKey(hSubKey);
                        RegCloseKey(hKey);
                        return;
                    }
                    RegCloseKey(hSubKey);

                    RegSetValueEx(hKey, szLayoutNum, 0, REG_SZ, (LPBYTE)pts,
                                  (DWORD)((CCH_LAYOUT_ID + 1) * sizeof(TCHAR)));
                }
            }
            else
            {
                if (RegOpenKeyEx(HKEY_CURRENT_USER, _T("Keyboard Layout\\Substitutes"), 0,
                                 KEY_ALL_ACCESS, &hSubKey) == ERROR_SUCCESS)
                {
                    RegSetValueEx(hSubKey, szPreload, 0, REG_SZ, (LPBYTE)pts,
                                  (DWORD)((CCH_LAYOUT_ID + 1) * sizeof(TCHAR)));

                    RegCloseKey(hSubKey);
                }
            }
        }
        else
        {
            if (_tcscmp(LangID, pts) == 0)
            {
                RegSetValueEx(hKey, szLayoutNum, 0, REG_SZ, (LPBYTE)pts,
                              (DWORD)((CCH_LAYOUT_ID + 1) * sizeof(TCHAR)));
            }
            else
            {
                if (RegCreateKeyEx(HKEY_CURRENT_USER, _T("Keyboard Layout\\Substitutes"), 0, NULL,
                                   REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,
                                   NULL, &hSubKey, NULL) == ERROR_SUCCESS)
                {
                    wsprintf(SubPath, _T("d%03d%s"), GetLayoutCount(Lang)-1, Lang);

                    RegSetValueEx(hSubKey, SubPath, 0, REG_SZ, (LPBYTE)pts,
                                  (DWORD)((CCH_LAYOUT_ID + 1) * sizeof(TCHAR)));

                    RegSetValueEx(hKey, szLayoutNum, 0, REG_SZ, (LPBYTE)SubPath,
                                  (DWORD)((CCH_LAYOUT_ID + 1) * sizeof(TCHAR)));

                    RegCloseKey(hSubKey);
                }
            }
        }

        RegCloseKey(hKey);
    }
}
Beispiel #13
0
static VOID
DeleteLayout(VOID)
{
    INT iIndex, LayoutNum;
    LVITEM item;
    HKEY hKey, hSubKey;
    HWND hLayoutList = GetDlgItem(MainDlgWnd, IDC_KEYLAYOUT_LIST);
    TCHAR szLayoutNum[3 + 1], szTitle[MAX_PATH],
          szConf[MAX_PATH], szPreload[CCH_LAYOUT_ID + 1];
    DWORD dwSize;

    iIndex = (INT) SendMessage(hLayoutList, LVM_GETNEXTITEM, -1, LVNI_FOCUSED);

    if (iIndex != -1)
    {
        LoadString(hApplet, IDS_REM_QUESTION, szConf, sizeof(szConf) / sizeof(TCHAR));
        LoadString(hApplet, IDS_CONFIRMATION, szTitle, sizeof(szTitle) / sizeof(TCHAR));

        if (MessageBox(MainDlgWnd, szConf, szTitle, MB_YESNO | MB_ICONQUESTION) == IDYES)
        {
            ZeroMemory(&item, sizeof(LVITEM));

            item.mask = LVIF_PARAM;
            item.iItem = iIndex;

            (VOID) ListView_GetItem(hLayoutList, &item);
            LayoutNum = (INT) item.lParam;

            if (RegOpenKeyEx(HKEY_CURRENT_USER, _T("Keyboard Layout\\Preload"), 0,
                             KEY_ALL_ACCESS, &hKey) == ERROR_SUCCESS)
            {
                _ultot(LayoutNum, szLayoutNum, 10);

                dwSize = sizeof(szPreload);
                RegQueryValueEx(hKey, szLayoutNum, NULL, NULL, (LPBYTE)szPreload, &dwSize);

                if (szPreload[0] == 'd')
                {
                    if (RegOpenKeyEx(HKEY_CURRENT_USER, _T("Keyboard Layout\\Substitutes"), 0,
                                     KEY_ALL_ACCESS, &hSubKey) == ERROR_SUCCESS)
                    {
                        if (RegDeleteValue(hSubKey, szPreload) != ERROR_SUCCESS)
                        {
                            RegCloseKey(hSubKey);
                            RegCloseKey(hKey);
                            return;
                        }
                        RegCloseKey(hSubKey);
                    }
                }

                if (RegDeleteValue(hKey, szLayoutNum) == ERROR_SUCCESS)
                {
                    UpdateLayoutsList();
                    UpdateRegValueNames(hKey);
                }
            }
            RegCloseKey(hKey);
        }
    }
}
Beispiel #14
0
int nugi( TCHAR *machine, TCHAR *user )
{
	DWORD rc;
	USER_INFO_3 *buf = 0;
	TCHAR temp[40];
	wchar_t unicodeMachine[UNCLEN + 4], unicodeUser[UNLEN + 2];
	static flag_t privilegeTexts[] =
	{
		{ USER_PRIV_GUEST, _T( "USER_PRIV_GUEST" ) },
		{ USER_PRIV_USER, _T( "USER_PRIV_USER" ) },
		{ USER_PRIV_ADMIN, _T( "USER_PRIV_ADMIN" ) },
		{ 0, 0 }
	};
	static flag_t authFlags[] =
	{
		{ AF_OP_PRINT, _T( "AF_OP_PRINT" ) },
		{ AF_OP_COMM, _T( "AF_OP_COMM" ) },
		{ AF_OP_SERVER, _T( "AF_OP_SERVER" ) },
		{ AF_OP_ACCOUNTS, _T( "AF_OP_ACCOUNTS" ) },
		{ 0, 0 }
	};
	static flag_t acctFlags[] =
	{
		{ UF_SCRIPT, _T( "UF_SCRIPT" ) },
		{ UF_ACCOUNTDISABLE, _T( "UF_ACCOUNTDISABLE" ) },
		{ UF_HOMEDIR_REQUIRED, _T( "UF_HOMEDIR_REQUIRED" ) },
		{ UF_PASSWD_NOTREQD, _T( "UF_PASSWD_NOTREQD" ) },
		{ UF_PASSWD_CANT_CHANGE, _T( "UF_PASSWD_CANT_CHANGE" ) },
		{ UF_LOCKOUT, _T( "UF_LOCKOUT" ) },
		{ UF_DONT_EXPIRE_PASSWD, _T( "UF_DONT_EXPIRE_PASSWD" ) },
#ifdef UF_ENCRYPTED_TEXT_PASSWORD_ALLOWED
		{ UF_ENCRYPTED_TEXT_PASSWORD_ALLOWED, _T( "UF_ENCRYPTED_TEXT_PASSWORD_ALLOWED" ) },
#endif
#ifdef UF_NOT_DELEGATED
		{ UF_NOT_DELEGATED, _T( "UF_NOT_DELEGATED" ) },
#endif
#ifdef UF_SMARTCARD_REQUIRED
		{ UF_SMARTCARD_REQUIRED, _T( "UF_SMARTCARD_REQUIRED" ) },
#endif
		{ UF_NORMAL_ACCOUNT, _T( "UF_NORMAL_ACCOUNT" ) },
		{ UF_TEMP_DUPLICATE_ACCOUNT, _T( "UF_TEMP_DUPLICATE_ACCOUNT" ) },
		{ UF_WORKSTATION_TRUST_ACCOUNT, _T( "UF_WORKSTATION_TRUST_ACCOUNT" ) },
		{ UF_SERVER_TRUST_ACCOUNT, _T( "UF_SERVER_TRUST_ACCOUNT" ) },
		{ UF_INTERDOMAIN_TRUST_ACCOUNT, _T( "UF_INTERDOMAIN_TRUST_ACCOUNT" ) },
		{ 0, 0 }
	};

#ifdef UNICODE
	_tcsncpy( unicodeMachine, machine, lenof( unicodeMachine ) );
	_tcsncpy( unicodeUser, user, lenof( unicodeUser ) );
#else
	mbstowcs( unicodeMachine, machine, lenof( unicodeMachine ) );
	mbstowcs( unicodeUser, user, lenof( unicodeUser ) );
#endif
	unicodeMachine[lenof( unicodeMachine ) - 1] = _T( '\0' );
	unicodeUser[lenof( unicodeUser ) - 1] = _T( '\0' );

	_tprintf( _T( "User %s on %s: " ), user, machine );

	rc = NetUserGetInfo( unicodeMachine, unicodeUser, 3, (byte **) &buf );
	if ( rc != 0 )
	{
		_tprintf( _T( "error %lu.\n" ), rc );
		return rc;
	}

	_tprintf( _T( "found.\n" ) );

	_tprintf( _T( "  Name:          %ls\n" ), buf->usri3_name );
	_tprintf( _T( "  Password:      %ls\n" ), buf->usri3_password );
	_tprintf( _T( "  Password age:  %lu days, %02lu:%02lu:%02lu\n" ), buf->usri3_password_age / 86400UL,
		buf->usri3_password_age % 86400UL / 3600UL, buf->usri3_password_age % 3600UL / 60UL,
		buf->usri3_password_age % 60UL );
	_tprintf( _T( "  Privilege:     %s\n" ), getText( buf->usri3_priv, privilegeTexts ) );
	_tprintf( _T( "  Home dir:      %ls\n" ), buf->usri3_home_dir );
	_tprintf( _T( "  Comment:       %ls\n" ), buf->usri3_comment );
	_tprintf( _T( "  Flags:         %s\n" ), buildFlags( buf->usri3_flags, acctFlags ) );
	_tprintf( _T( "  Script path:   %ls\n" ), buf->usri3_script_path );
	_tprintf( _T( "  Auth flags:    %s\n" ), buildFlags( buf->usri3_auth_flags, authFlags ) );
	_tprintf( _T( "  Full name:     %ls\n" ), buf->usri3_full_name );
	_tprintf( _T( "  User comment:  %ls\n" ), buf->usri3_usr_comment );
	_tprintf( _T( "  RAS params:    (not displayed)\n" ) );
	_tprintf( _T( "  Workstations:  %ls\n" ), buf->usri3_workstations );
	_tprintf( _T( "  Last logon:    %s" ), buf->usri3_last_logon == 0? _T( "never\n" ): _tctime( (long *) &buf->usri3_last_logon ) );
	_tprintf( _T( "  Last logoff:   %s" ), buf->usri3_last_logoff == 0? _T( "unknown\n" ): _tctime( (long *) &buf->usri3_last_logoff ) );
	_tprintf( _T( "  Expires:       %s" ), buf->usri3_acct_expires == TIMEQ_FOREVER? _T( "never\n" ): _tctime( (long *) &buf->usri3_acct_expires ) );
	_tprintf( _T( "  Max storage:   %s\n" ), buf->usri3_max_storage == USER_MAXSTORAGE_UNLIMITED? _T( "unlimited" ): _ultot( buf->usri3_max_storage, temp, 10 ) );
	_tprintf( _T( "  Logon hours:   (not displayed)\n" ) );
	_tprintf( _T( "  Bad PW count:  %s\n" ), buf->usri3_bad_pw_count == (DWORD) -1L? _T( "unlimited" ): _ultot( buf->usri3_bad_pw_count, temp, 10 ) );
	_tprintf( _T( "  # of logons:   %s\n" ), buf->usri3_num_logons == (DWORD) -1L? _T( "unknown" ): _ultot( buf->usri3_num_logons, temp, 10 ) );
	_tprintf( _T( "  Logon server:  %ls\n" ), buf->usri3_logon_server );
	_tprintf( _T( "  Country code:  %lu\n" ), buf->usri3_country_code );
	_tprintf( _T( "  Code page:     %lu\n" ), buf->usri3_code_page );
	_tprintf( _T( "  User RID:      %lu\n" ), buf->usri3_user_id );
	_tprintf( _T( "  Pgroup RID:    %lu\n" ), buf->usri3_primary_group_id );
	_tprintf( _T( "  Profile path:  %ls\n" ), buf->usri3_profile );
	_tprintf( _T( "  Home drive:    %ls\n" ), buf->usri3_home_dir_drive );
	_tprintf( _T( "  PW expired:    %s\n" ), buf->usri3_password_expired? _T( "yes" ): _T( "no" ) );
	_tprintf( _T( "\n" ) );

	return 0;
}
void BinValToStrSimle(
    const BINVAL_TYP*    pVal,
    FC_CString*          pStr          //c-like value string
)
{
    TCHAR buffer[256];

    switch(pVal->typ) 
    {
    case BL_BOOL:
        buffer[0] = pVal->aBOOL ? _T('1') : _T('0');
        buffer[1] = 0;
    break;
    case BL_BYTE:
        buffer[0] = '0';
        buffer[1] = 'x';
        _ltot(pVal->aBYTE & 0xff, buffer+2, 16);
    break;
    case BL_WORD:
        buffer[0] = '0';
        buffer[1] = 'x';
        _ltot(pVal->aWORD & 0xffff, buffer+2, 16);
    break;
    case BL_UINT:
        _ultot(pVal->aWORD & 0xffff, buffer, 10);
    break;
    case BL_INT:
        _ltot(pVal->aINT, buffer, 10);
    break;
    case BL_DWORD:
        buffer[0] = '0';
        buffer[1] = 'x';
        _ltot(pVal->aDWORD, buffer+2, 16);
    break;
    case BL_UDINT:
        _ultot(pVal->aDWORD, buffer, 10);
    break;
    case BL_DINT: 
        _ltot(pVal->aDINT, buffer, 10);
    break;
    case BL_LWORD:
        buffer[0] = '0';
        buffer[1] = 'x';
        _ui64tot(pVal->aLWORD, buffer+2, 16);
    break;
    case BL_LINT:
        _ui64tot(pVal->aLINT, buffer, 10);
    break;
    case BL_REAL:
        if(pVal->aREAL != 0.0)
            _stprintf(buffer, _T("%.8e"), (double)pVal->aREAL);                  
        else
            _tcscpy(buffer, _T("0"));
    break;
    case BL_LREAL:    
        if(pVal->aLREAL != 0.0)
            _stprintf(buffer, _T("%.17e"), pVal->aLREAL);
        else
            _tcscpy(buffer, _T("0"));
    break;
    case BL_TOD:
        _ltot(pVal->aTOD, buffer, 10);
    break;
    case  BL_DATE:
        _ltot(pVal->aDATE, buffer, 10);
    break;
    case  BL_TIME:
        _ui64tot(pVal->aTIME, buffer, 10);
    break;
    case  BL_DT:
        _ui64tot(pVal->aDT, buffer, 10);
    break;
    case BL_STRING:
    case BL_WSTRING:
        pStr->load(pVal->pszStr); //HACK
        return;
    break;
    default:
        assert(!"data type not supported");
        pStr->load(_T("<data type not supported>"));
        return;
    }

    pStr->load(buffer);
}
//===========================================================================
void RegSaveValue (LPCTSTR section, LPCTSTR key, BOOL peruser, DWORD value) {
  TCHAR buffer[32] = TEXT("");
  _ultot(value,buffer,10);
  RegSaveString(section,key,peruser,buffer);
}