Sergio Calderon
Sergio Calderon

Reputation: 867

Show variables in a MessageBox function?

Is there any way I can show different types of variables in a MessageBox? I'm working with the Windows API, and I have for example this function:

long R1 = RegOpenKeyEx(hKey, lpSubKey, ulOptions,
                             samDesired, &phkResult);

The phkResult returns the pointer to the Opened Registry Key, so I would like to show that Registry Key path in a MessageBox.

Can I do that?

Thanks!

Upvotes: 0

Views: 144

Answers (1)

Abhineet
Abhineet

Reputation: 5409

Unicode:: MessageBoxW( 0, lpSubKey, L"Reg Key Path", MB_OK ) ;
ANSI:: MessageBoxA( 0, lpSubKey, "Reg Key Path", MB_OK ) ;

Also, if you need the full path with RootKey too, then you have to put that in buffer like::

TCHAR tszRegKeyPath[MAX_PATH] = {0} ;
StringCchPrintf( tszRegKeyPath, _countof(tszRegkeyPath),\
 TEXT("__Put_Here_The_Reg_Key_Name_For_Which_You_Have_The_hKey\\%s"), lpSubKey ) ;
MessageBox( 0, tszRegKeyPath, TEXT("Reg Key Path"), MB_OK ) ;

Upvotes: 2

Related Questions