That's correct, so the problem is in your unmanaged code. How is m_Devices declared? What codepage is Windows set up for? Are you using a different codepage for your Console? Also, since your using just printf and not tprintf, this tells me you're not using ASCII on Windows and Unicode on Windows NT (like Auto dictates), so use CharSet.Ansi instead (if this is the case). Like I said before, you should read the documentation, not just expect the exact answer (especially when you don't provide enough details to say for sure). One thing I would warn you about as well is that it's actually a bad idea to return strings from functions. I don't remember all the details (it's been a while since I was hot n' heavy into C/C++), but you should instead declare your function like so:
__declspec(dllexport) void GetString(INT i, LPSTR lpszText, DWORD cbText);
Also notice my use of INT (declared as int, and it's typically better to use pre-proc defs). The lpszText param is both [in,out], and the cbText ([in]) is the max string length. Without this protection, you open your code up - and potentially your entire system - to buffer overruns (the leading cause of security threats). This signature is common for functions and structs throughout the Windows APIs. Your managed declaration would then look like this (taking into account that is seems you're using ASCII only strings since you're using printf[DllImport("pciDriver.dll", CharSet=CharSet.Ansi)] private static extern void GetString( int i, [In, Out] string lpszText, [MarshalAs(UnmanagedType.U4)] int cbSize);Technically, however, the first param - `i` - should be an `IntPtr`. An `int` in C# refers to `Int32`, which is always 32 bits. An `int` in C/C++ is the width of the processor, so 32 bits on a 32-bit processor and 64 bits on a 64-bit processor (depends on the compiler, really). An `IntPtr` is like that. If you wanted to make your code more portable to other architectures, then change the param type to `IntPtr` and when you pass it, pass it as `new IntPtr(0)` (or whatever index you need). Microsoft MVP, Visual C#[](</x-turndown)