widestring

How to pass wide strings in Java calling the MessageBoxW function in user32 lib

微笑、不失礼 提交于 2021-01-28 04:34:05
问题 I am currently struggling to use the function MessageBoxW in Java. I have managed to successfully call the user32 library and use the MessageBoxA function. Here's my code below: package messagebox; import com.sun.jna.Library; import com.sun.jna.Native; public class MessageBox { public interface user32 extends Library { public int MessageBoxA(int something, String text, String caption, int flags); } public static void main(String[] args) { System.out.println("Program starting... Library

Combining wide string literal with string macro

孤人 提交于 2020-02-24 03:38:06
问题 I have a macro for a character string as follows: #define APPNAME "MyApp" Now I want to construct a wide string using this macro by doing something like: const wchar_t *AppProgID = APPNAME L".Document"; However, this generates a "concatenating mismatched strings" compilation error. Is there a way to convert the APPNAME macro to a wide string literal? 回答1: Did you try #define APPNAME "MyApp" #define WIDEN2(x) L ## x #define WIDEN(x) WIDEN2(x) const wchar_t *AppProgID = WIDEN(APPNAME) L"

Combining wide string literal with string macro

主宰稳场 提交于 2020-02-24 03:37:11
问题 I have a macro for a character string as follows: #define APPNAME "MyApp" Now I want to construct a wide string using this macro by doing something like: const wchar_t *AppProgID = APPNAME L".Document"; However, this generates a "concatenating mismatched strings" compilation error. Is there a way to convert the APPNAME macro to a wide string literal? 回答1: Did you try #define APPNAME "MyApp" #define WIDEN2(x) L ## x #define WIDEN(x) WIDEN2(x) const wchar_t *AppProgID = WIDEN(APPNAME) L"

Should I pass a mutable reference or transfer ownership of a variable in the context of FFI?

假装没事ソ 提交于 2020-01-14 05:17:28
问题 I have a program that utilizes a Windows API via a C FFI (via winapi-rs). One of the functions expects a pointer to a pointer to a string as an output parameter. The function will store its result into this string. I'm using a variable of type WideCString for this string. Can I "just" pass in a mutable ref to a ref to a string into this function (inside an unsafe block) or should I rather use a functionality like .into_raw() and .from_raw() that also moves the ownership of the variable to the

When and why can sprintf fail?

北城余情 提交于 2020-01-13 11:03:16
问题 I'm using swprintf to build a string into a buffer (using a loop among other things). const int MaxStringLengthPerCharacter = 10 + 1; wchar_t* pTmp = pBuffer; for ( size_t i = 0; i < nNumPlayers ; ++i) { const int nPlayerId = GetPlayer(i); const int nWritten = swprintf(pTmp, MaxStringLengthPerCharacter, TEXT("%d,"), nPlayerId); assert(nWritten >= 0 ); pTmp += nWritten; } *pTaskPlayers = '\0'; If during testing the assert never hits, can I be sure that it will never hit in live code? That is,

Converting wide char string to lowercase in C++

别说谁变了你拦得住时间么 提交于 2019-12-30 09:07:21
问题 How do I convert a wchar_t string from upper case to lower case in C++? The string contains a mixture of Japanese, Chinese, German and Greek characters. I thought about using towlower... http://msdn.microsoft.com/en-us/library/8h19t214%28VS.80%29.aspx .. but the documentation says that: The case conversion of towlower is locale-specific. Only the characters relevant to the current locale are changed in case. Edit: Maybe I should describe what I'm doing. I receive a Unicode search query from a

Passing file path in Delphi from TOpenDialog as a string

早过忘川 提交于 2019-12-24 21:35:33
问题 I'm trying to make use of the TOpenDialog in order to pass the path to selected file to the AdoConection and load the content of the Excel file to the table. I'm currently attempting the code below but the last part of the code does not connect to the Excel returning an error: [dcc32 Error] sample_map.pas(80): E2010 Incompatible types: 'string' and 'TOpenDialog' procedure TForm1.Button1Click(Sender: TObject); var openDialog : TOpenDialog; // Open dialog variable strConn : WideString; //

cannot convert from 'const char *' to 'LPCTSTR'

雨燕双飞 提交于 2019-12-19 05:10:15
问题 I'm trying to convert string to 'LPCTSTR', but, i got following error. Error : cannot convert from 'const char *' to 'LPCTSTR' code: std::string str = "helloworld"; LPCTSTR lp = str.c_str(); Also, tried : LPCTSTR lp = (LPCTSTR)str.c_str(); But, print garbage value. 回答1: LPCTSTR means (long pointer to constant TCHAR string). A TCHAR can either be wchar_t or char based on what your project settings are. If, in your project settings, in the "General" tab, your character set is "Use Multi-byte

Is it necessary to convert string to WideString in Delphi?

女生的网名这么多〃 提交于 2019-12-18 12:14:13
问题 I found a Windows API function that performs "natural comparison" of strings. It is defined as follows: int StrCmpLogicalW( LPCWSTR psz1, LPCWSTR psz2 ); To use it in Delphi, I declared it this way: interface function StrCmpLogicalW(psz1, psz2: PWideChar): integer; stdcall; implementation function StrCmpLogicalW; external 'shlwapi.dll' name 'StrCmpLogicalW'; Because it compares Unicode strings, I'm not sure how to call it when I want to compare ANSI strings. It seems to be enough to cast

C++ consuming delphi DLL

♀尐吖头ヾ 提交于 2019-12-11 04:02:31
问题 I'm not able to use the function of a dll developed in delphi. I'm having some difficulties with the conversions of types. This is the function I want to call the DLL: function rData(ID: Cardinal; queue: WideString): WideString; stdcall; My code in C++ was so: typedef string (*ReturnDataSPL)(DWORD, string); string result; HMODULE hLib; hLib = LoadLibrary("delphi.dll"); pReturnDataSPL = (ReturnDataSPL)GetProcAddress(hLib,"rData"); if (NULL != pReturnDataSPL) result = pReturnDataSPL(JobID