I am stuck on these C++ data types const wchar_t * since last week.
It worked well in C# console application under mentioned below
Expand|Select|Wrap|Line Numbers
- unsafe static void Main(string[] args)
- {
- IntPtr ld, data1, data2;
- string str = "test.txt";
- int UTF_8 = 1;
- // Using PInvoke
- [System.Runtime.InteropServices.DllImportAttribute("Test.dll", EntryPoint = "LoadFromFile")]
- public static extern System.IntPtr LoadFromFile(System.IntPtr aObj, System.IntPtr ex, [System.Runtime.InteropServices.InAttribute()] [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.LPWStr)] string aPath, int aWritable);
- [System.Runtime.InteropServices.DllImportAttribute("Test.dll", EntryPoint = "LoadFromFile_cset")]
- public static extern System.IntPtr LoadFromFile_cset(System.IntPtr aObj, System.IntPtr ex, int aEncoding, [System.Runtime.InteropServices.InAttribute()] [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.LPStr)] string aPath, int aWritable);
- // data1 and data2 should have some address
- // get some address in console application heredata1 = LoadFromFile(ld, IntPtr.Zero, str, 1);
- data2 = LoadFromFile_cset(ld, IntPtr.Zero, UTF_8, str, 1);
- // but I got can't get any address in C# Window Form
- }
Expand|Select|Wrap|Line Numbers
- struct Doc *API LoadFromFile (struct Loader * aObj, struct Exception * ex, const wchar_t * aPath, int aWritable)
- struct Doc *API LoadFromFile_cset (struct Loader * aObj, struct Exception * ex, int aEncoding, const char * aPath, int aWritable)
But very strange for this time since I am using other party libraries so I couldn't debug inside.
I hope some one will advise me since I need to close the case by tomorrow.
Thanks and best regards