2015-10-02 3 views
0

J'ai besoin d'utiliser des chaînes dans mon application Winapi C/C++ à partir de ressources système qui se trouvent dans windows/system32/et qui ont l'extension * .mui. F.e. winload.exe.mui.Comment utiliser les ressources système mui dans Winapi C/C++?

programme « hacker ressources » donnez-moi ceci:

1 MESSAGETABLE 
{ 
0x40000001,  "Обновление системы... (%5!Iu!%%)%r%0\r\n" 
0xC0000002,  "Ошибка %4!lX! при операции обновления %1!Iu! из %2!Iu! (%3)%r%0\r\n" 
0xC0000003,  "Неустранимая ошибка %4!lX! при операции обновл. %1!Iu! из %2!Iu! (%3)%r%0\r\n" 
} 

Comment puis-je extraire la chaîne avec adresse 0x40000001 et utiliser dans mon application winapi?

+0

[FindResourceEx] (https://msdn.microsoft.com/en-us/library/windows/desktop/ms648043.aspx). – IInspectable

+0

Comme ça? HMODULE resContainer = LoadLibrary (L "C: \\ Windows \\ System32 \\ ru-RU \\ poqexec.exe.mui"); HRSRC myResource = FindResource (resContainer, MAKEINTRESOURCE (0x40000001), RT_MESSAGETABLE); HGLOBAL myResourceData = LoadResource (resContainer, myResource) –

Répondre

0

besoin d'utiliser FormatMessage

HMODULE resContainer = LoadLibrary(L"C:\\Windows\\System32\\ru-RU\\poqexec.exe.mui"); 

LPTSTR pBuffer; // Buffer to hold the textual error description. 
if (FormatMessage(
    FORMAT_MESSAGE_ALLOCATE_BUFFER | // Function will handle memory allocation. 
    FORMAT_MESSAGE_FROM_HMODULE | // Using a module's message table. 
    FORMAT_MESSAGE_IGNORE_INSERTS, 
    resContainer, // Handle to the DLL. 
    0x40000001, // Message identifier. 
    MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language. 
    (LPTSTR)&pBuffer, // Buffer that will hold the text string. 
    256, // Allocate at least this many chars for pBuffer. 
    NULL // No insert values. 
    )) 
{ 
    MessageBox(0, pBuffer, 0, 0); 
    LocalFree(pBuffer); 
}