For your P/Invoke declaration, the
parameter should be an
, not a
. The parameter is a 32-bit integer, whereas
is a 64-bit integer.
parameter and return values should be
, since their size depends on whether you're running as a 32-bit or 64-bit process.
When you expect the function to update a string parameter, you should pass a
. In .NET, the
type is immutable.
However, from what I've read, when the window belongs to another process, you have to allocate a buffer for the name in that process. This means you'll need to call
, and finally
There's a two-part MSDN blog post from 2006 with the C# code to do this: