some keys are verified quicker than others, i think dependant on which xrm-ms is being used. i don't think the code has anything to do with it. if you are interested in my source (VBnet) shoot me a PM.
You probably used some other method now but.... Using your example, you can call the function using something like this: Code: // In some function..... IntPtr dllHandle = LoadLibrary("ProductKeyUtilities.dll"); IntPtr pAddressOfFunctionToCall = GetProcAddress(dllHandle, "PidGenX"); var PidGenX = Marshal.GetDelegateForFunctionPointer(pAddressOfFunctionToCall, typeof(PidGenXDelegate)); PidGenX(productKeyHere, pKeyPathHere, MSPIDHere, OEMIDHere, ProductIDHere, DigitalProductIDHere); // Global declerations [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate int PidGenXDelegate(string ProductKey, string PkeyPath, string MSPID, string OEMID, IntPtr ProductID, IntPtr DigitalProductID, IntPtr DigitalProductID4); Of course, you'd only need to call LoadLibrary, and generate the delegate once instead of doing it each time you needed to use the function. Then when you're all done, cleanup using FreeLibrary. EDIT - Seems like Calistoga already bet me to it. You said it didn't work. It might because Calistoga's example did not explicitly specify the UnmanagedFunctionPointerAttribute. Make sure that your exported function's calling convention matches the once in the attribute too. Also make that you use the MarshalAs attributes on each string parameter in the delegate because the marshaller won't know what type of string you've used (eg. LPSTR, LPWSTR, etc). For example, if all the strings were LPWSTR, the delegate would look like this: Code: [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate int PidGenXDelegate([MarshalAs(UnmanagedType.LPWStr)] string ProductKey, [MarshalAs(UnmanagedType.LPWStr)] string PkeyPath, [MarshalAs(UnmanagedType.LPWStr)] string MSPID, [MarshalAs(UnmanagedType.LPWStr)] string OEMID, IntPtr ProductID, IntPtr DigitalProductID, IntPtr DigitalProductID4);