⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 langload.cpp

📁 在windows的资源文件中使用多语言从而实现多语言支持
💻 CPP
字号:
// sample showing how to use language IDs and LoadString
//
// (C) Copyright 1999 by Mike Blaszczak
// written on 18 October, 1999 for Visual C++ 6.0

// regular headers...

#include <windows.h>
#include <stdio.h>

// plus our own header to get the definition of the ID in our resource

#include "langload.h"

#if defined(_UNICODE) || defined(UNICODE)
#error I didn't write this sample to support Unicode.
#endif

void main()
{
   // save the old locale
   LCID oldLCID = GetThreadLocale();

   TCHAR sz[1024];

   // try to load the English string

   SetThreadLocale(
      MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT));

   int nLoaded = LoadString(GetModuleHandle(NULL), IDS_COWS, sz, 1024);
   if (nLoaded > 0)
   {
      printf("LoadString worked!\n");
      printf("%s\n", sz);
   }
   else
      printf("LoadString failed: %d\n", GetLastError());

   // try to load the French string

   SetThreadLocale(
      MAKELCID(MAKELANGID(LANG_FRENCH, SUBLANG_FRENCH), SORT_DEFAULT));

   nLoaded = LoadString(GetModuleHandle(NULL), IDS_COWS, sz, 1024);
   
   if (nLoaded > 0)
   {
      printf("LoadString worked!\n");
      printf("%s\n", sz);
   }
   else
      printf("LoadString failed: %d\n", GetLastError());

   // set the old LCID one back
   SetThreadLocale(oldLCID);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -