フリーソフト

Windows

[VC++] 標準入力に入力されたパスワードを隠す方法

http://ja.softuses.com/188813

-------------------------
#include<iostream>
#include<string>
#include<conio.h>

int main()
{
  std::string password;
  char ch;
  const char ENTER = 13;

  std::cout << "enter the password: ";
  while ((ch = _getch()) != ENTER) {
    password += ch;
    std::cout << '*';
  }
}
-------------------------

Cryptographic API(CryptoAPI、CAPI)を使ってMD5などのハッシュ値を求める

Cryptographic API(CryptoAPI、CAPI)
 http://msdn.microsoft.com/en-us/library/aa380256.aspx

//---------------------------------------------------------------------------
UnicodeString __fastcall CalcHash(UnicodeString Str)
{
  UnicodeString Result="";
  HCRYPTPROV hCryptProv = NULL;
  HCRYPTHASH hHash = NULL;

  if (!::CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL, 0)) {
    if(!::CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL, CRYPT_NEWKEYSET)) {
      return Result;
    }
  }

  try {
    if (!::CryptCreateHash(hCryptProv, CALG_MD5, 0, 0, &hHash)) return Result;
    try {
      AnsiString TmpStr=Str;
      if (!::CryptHashData(hHash, (BYTE*)TmpStr.c_str(), (DWORD)TmpStr.Length(), 0)) return Result;
      BYTE bData[1024];
      memset(bData, 0, sizeof(bData));
      CHAR Digits[] = "0123456789abcdef";
      DWORD dwDataLen = 16;
      if (!::CryptGetHashParam(hHash, HP_HASHVAL, bData, &dwDataLen, 0)) return Result;
      Result="";
      for (DWORD i = 0; i < dwDataLen; ++i) {
        Result+=Digits[bData[i] >> 4];
        Result+=Digits[bData[i] & 0xf];
      }
    } __finally {
      if (hHash) ::CryptDestroyHash(hHash);
    }
  } __finally {
    if (hCryptProv) ::CryptReleaseContext(hCryptProv,0);
  }
  return Result;
}

[BCB] DLLを動的に読み込む

HMODULE LoadLibrary(LPCTSTR lpFileName);

FARPROC GetProcAddress(HMODULE hModule, LPCSTR lpProcName);

BOOL FreeLibrary(HMODULE hModule);

[Windows] 「最近使ったファイル」を消す

HKEY_CURRENT_USER\Software\Microsoft\Windows\
CurrentVersion\Policies\Explorer\

メニューを消す
NoRecentDocsMenu DWORDで値 1

更新しない
NoRecentDocsHistory DWORDで値 1