mirror of
https://github.com/janbodnar/Windows-API-examples.git
synced 2026-08-07 18:34:45 -04:00
Create winapi_shell_convert.c
This commit is contained in:
parent
b78d2a077e
commit
bcc62396ae
37
strings/winapi_shell_convert.c
Normal file
37
strings/winapi_shell_convert.c
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
#include <windows.h>
|
||||||
|
#include <wchar.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include "Shlwapi.h"
|
||||||
|
|
||||||
|
#pragma comment(lib, "Shlwapi.lib")
|
||||||
|
|
||||||
|
int wmain(void) {
|
||||||
|
|
||||||
|
wchar_t str1[] = L"512";
|
||||||
|
wchar_t str2[] = L"0xAB12";
|
||||||
|
int n = 0;
|
||||||
|
|
||||||
|
bool r = StrToIntExW(str1, STIF_DEFAULT, &n);
|
||||||
|
|
||||||
|
if (r == true) {
|
||||||
|
|
||||||
|
wprintf(L"The value is %d\n", n);
|
||||||
|
} else {
|
||||||
|
|
||||||
|
wprintf(L"The first conversion failed\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
r = StrToIntExW(str2, STIF_SUPPORT_HEX, &n);
|
||||||
|
|
||||||
|
if (r == true) {
|
||||||
|
|
||||||
|
wprintf(L"The value is %d\n", n);
|
||||||
|
} else {
|
||||||
|
|
||||||
|
wprintf(L"The second conversion failed\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user