Load Win32 dll
Posted on 2005-04-19
i have a win32 dll that i want to import into my program, and it has one function i need.. the code to import is below
private static extern IntPtr GetHashHex(IntPtr source, System.UInt16 key);
private static extern IntPtr GetHashHex(char source, System.UInt16 key);
the MSUtils.dll is written in Delphi, and the declaration of that function is:
function GetHashHex(SourceStr: Array of Char; Key: word): PChar; stdcall;
when i call the function declared in the first example, the function sometimes (randomly) succeeds, but it returns a bad pointer IntPtr, which is some value, i cant use...
and when i call the function declared in the second example, the function succeeds, only when i pass small arrays (~300), if char array is larger than 300 (or some near it value), the program throws nullpointer exception...
how should i declare and use that function? and how should i use it?
do i need to allocate some memory or other stuff?
thanks in advance