Вопрос по .net, visual-c++, winapi – 'System :: String ^' в 'LPCWSTR'

10

Я хочу конвертироватьSystem::String ^ вLPCWSTR.

за

FindFirstFile(LPCWSTR,WIN32_FIND_DATA); 

Пожалуйста помоги.

Error: User Rate Limit Exceeded heavyd
Error: User Rate Limit Exceeded Rick2047

Ваш Ответ

4   ответа
0

Error: User Rate Limit Exceeded

String^ str = "C:\\my.dll";

::LoadLibraryEx(LPCWSTR)Marshal::StringToHGlobalAnsi(str).ToPointer(), 0, flags); 

Error: User Rate Limit Exceeded

#include <atlstr.h>

CString s("C:\\my.dll");
::LoadLibraryEx((LPCWSTR)s, 0, flags);

Error: User Rate Limit Exceeded

10

Error: User Rate Limit ExceededError: User Rate Limit ExceededError: User Rate Limit Exceeded

System::String ^str = "Hello World";

IntPtr ptr = System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(str);

HANDLE hFind = FindFirstFile((LPCSTR)ptr.ToPointer(), data);

System::Runtime::InteropServices::Marshal::FreeHGlobal(ptr);
24

Error: User Rate Limit Exceededpin_ptr:

#include <vcclr.h>

void CallFindFirstFile(System::String^ s)
{
    WIN32_FIND_DATA data;
    pin_ptr<const wchar_t> wname = PtrToStringChars(s);
    FindFirstFile(wname, &data);
}
Error: User Rate Limit ExceededwnameError: User Rate Limit ExceededsError: User Rate Limit ExceededconstError: User Rate Limit Exceeded
2

Error: User Rate Limit ExceededError: User Rate Limit Exceeded

Error: User Rate Limit ExceededDllImportError: User Rate Limit Exceeded

 [DllImport("kernel32.dll", CharSet=CharSet.Auto)]
 static extern IntPtr FindFirstFile
     (string lpFileName, out WIN32_FIND_DATA lpFindFileData);

Error: User Rate Limit Exceeded

[Edit]Error: User Rate Limit ExceededError: User Rate Limit ExceededError: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

Похожие вопросы