I’m a beginner programmer. I’m writing a project in C++ (the only programming language I understand). I needed a GUI and decided to write it in C# WPF.
I’ll explain the meaning of the application: you need to load the dll file into the C# editor so that you can work with it later. I decided to load it via C++ LoadLibraryW. The following code does this:
#ifndef EDITOR_INTERFACE
#define EDITOR_INTERFACE extern “C” __declspec(dllexport)
#endif
EDITOR_INTERFACE uint32_t LoadDll(const wchar_t* dll_path)
{
if (game_code_dll) return 0;
game_code_dll = LoadLibraryW(dll_path);
assert(game_code_dll);
if (game_code_dll != nullptr) return 1;
else return 0;
}
Next, I exported this function to C# code:
namespace Editor.DllWrappers
{
public static class Utilities
{
private const string _dllName = "EngineDLL.dll";
[DllImport(_engineDLLName, CharSet = CharSet.Unicode)]
public static extern int LoadGameCodeDll(string dll_path);
}
}
For some reason, when Iyour text
pass the path and it goes into C++ code, it turns into Chinese characters
I spent 3 hours unsuccessfully debugging and 2 hours searching the Internet for information.
I don’t understand why this is happening and I would appreciate any help.
This is my first question and I still don’t know how to ask them correctly.
Матвей Жуковский is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.