string s = "C:\\ok.bmp";
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, (void*)s.c_str(), SPIF_SENDCHANGE);
This doesnt work ^^ and the ok.bmp is inside of the folder!
Most builds are Unicode nowadays, so try with a Unicode string:
wstring ws = L"C:\\ok.bmp";
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, ws.data(), SPIF_SENDCHANGE);
(by using std::wstring::data(), you don't need the cast).
Related
I can't implement the definition of the MaxCLL, MaxFall, MasteringDisplayColorPrimaries parameters using the MediaInfo.h library. Calling other parameters works fine.
I tried the following commands:
std::wstring maxCll = MI.Get(Stream_Video, 0, L"maximum_content_light_level");
std::wstring maxFall = MI.Get(Stream_Video, 0, L"maximum_frameaverage_light_level");
std::wstring mastering_display_color_primaries = MI.Get(Stream_Video, 0, L"mastering_display_color_primaries");
Field names are "MaxCLL", "MaxFALL", "MasteringDisplay_ColorPrimaries", "MasteringDisplay_Luminance".
Generally speaking, you can get the field names from e.g. the XML or JSON outputs or mediainfo -f --Language=raw.
Note: I also answered on the MediaInfo forum topic.
I've tried to develop an NSIS Plugin in C++.
Here is my method to set informations from NSIS:
void __declspec(dllexport) SetCredentials(HWND hWndParent, int string_size, TCHAR *variables, stack_t **stacktop, extra_parameters *extra) {
EXDLL_INIT();
server = getuservariable(INST_0);
port = myatou(getuservariable(INST_1));
database = getuservariable(INST_2);
username = getuservariable(INST_3);
password = getuservariable(INST_4);
MessageBox(hWndParent, server, L"Info", MB_OK); // Here is the problem
setuservariable(INST_0, server);
}
Sample:
OutFile "Example.exe"
BrandingText " "
Section
MySQL::SetCredentials "localhost" 3306 "banananode" "root" ""
Pop $0
MessageBox MB_OK "Server: $0" ; Returns the server value...
SectionEnd
The Problem is, when i try to print out the server variable, chinese characters will be shown, not the correct text:
When i return the value with setuservariable(INST_0, server);, NSIS will be display it correctly:
Can you tell me, whats wrong?
I've tried to build the resulted .dll with pluginapi-x86-ansi.lib and pluginapi-x86-unicode.lib but the result is the same...
ANSI characters interpreted as Unicode (UTF-16LE) tends to look Chinese.
When you create a Unicode plug-in you need to:
Make sure UNICODE and _UNICODE is defined in your project/.C files.
Link with pluginapi-x86-unicode.lib
Add Unicode True to your .NSI
Place the plug-in in \NSIS\x86-unicode
In your case you most likely forgot about Unicode True. Returning the value works because you never actually changed the memory of server, it is still the same input string.
I'm using windows OS and trying to write ACE_Tstring that contains multiple languages sentence(by Unicode) to a file using ACE_OS::write().
But the result I'm getting in the file is unpredictable characters(gibberish text).
This is my code implemented :
ACE_Tstring *str = new ACE_Tstring(L"مرحبا привет świecie Hello")
ACE_HANDL hFile = ACE_OS::open(L"myfile", _O_WRONLY);
ACE_OS::write(hFile, str, 1048);
wprintf(L"%ls",str->c_str());
As you can see I also print the string to the screen, and on screen I get the characters "????" where any character accept for English characters appear.
Written Text
مرحبا привет świecie Hello
Result on Screen :
?????? ????? ??????? Hello
What am I missing and what is wrong with my code?
ACE_TString is a typedef for ACE_CString when ACE_USES_WCHAR is not set. Try using ACE_WString if you need to force it to wide-chars.
I want to submit a form using the CHttpFile::SendRequest and save those data to a mysql database. The field inside the DB table collation is also set to utf8mb4_unicode_ci.
It works fine except the character encoding for the non-english chars. My app is under MFC and "character set" is no set which means ASCII. I tried to convert the chars to unicode without success.
CString strFormData;
strFormData = _T(SUBMIT_FORM) + _T(strSubmitValue) + _T(USERNAME_FIELD) + _T(m_strUsername) + _T(RESTORE_EMAIL_FIELD) + _T(m_strRestoreEmail) + _T(CAPTCHA_FIELD);
LPWSTR lpUnicodeFormData = A2W( strFormData );
strHeaders = _T("Content-Type: application/x-www-form-urlencoded;charset=UTF-8\r\n");
result = pFile->SendRequest(strHeaders, (LPVOID) (LPCTSTR) lpUnicodeFormData, wcslen(lpUnicodeFormData));
What am i doing wrong here ?
Inside PHP file where the html form exists, I added the code
mysqli_set_charset($con, "utf8");
This solved the problem.
thank you to all.
Tried googling for a few hours, testing different solutions for hours but still just cannot get this to work.
I need a const url base (Ex. http://www.google.com)
Then I need a string input from the user (ex. Mountain Dew) and then combine them.
I've tried making the URL a LPCWSTR, wstring, wchar_t, doing a function to convert them and combine them but I cannot get it to work at all.
std::string baseUrl = "http://www.google.com/";
std::string userAdd;
getline(std::cin, userAdd)
ShellExecute(NULL, TEXT("open"), baseUrl + userAdd, NULL, NULL, SW_SHOWNORMAL);
There's no automatic conversion from std::string to const char*.
Try this: (baseUrl + userAdd).c_str()
and try using ShellExecuteA