UI: add a dialog that shows local hardware IDs
This commit is contained in:
parent
482e8bf3e2
commit
a4130ba373
10 changed files with 260 additions and 42 deletions
40
StringUtils.cpp
Normal file
40
StringUtils.cpp
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
#include "StringUtils.h"
|
||||
#include <string>
|
||||
|
||||
const char* StringUtils::wchar_to_char(const wchar_t* pwchar)
|
||||
{
|
||||
if (pwchar == nullptr)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
// get the number of characters in the string.
|
||||
int currentCharIndex = 0;
|
||||
char currentChar = pwchar[currentCharIndex];
|
||||
|
||||
while (currentChar != '\0')
|
||||
{
|
||||
currentCharIndex++;
|
||||
currentChar = pwchar[currentCharIndex];
|
||||
}
|
||||
|
||||
const int charCount = currentCharIndex + 1;
|
||||
|
||||
// allocate a new block of memory size char (1 byte) instead of wide char (2 bytes)
|
||||
char* filePathC = (char*)malloc(sizeof(char) * charCount);
|
||||
|
||||
for (int i = 0; i < charCount; i++)
|
||||
{
|
||||
// convert to char (1 byte)
|
||||
char character = pwchar[i];
|
||||
|
||||
*filePathC = character;
|
||||
|
||||
filePathC += sizeof(char);
|
||||
|
||||
}
|
||||
filePathC += '\0';
|
||||
|
||||
filePathC -= (sizeof(char) * charCount);
|
||||
|
||||
return filePathC;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue