ok, i will look into this... at the moment struggling to get my COM object to work on X64 system, damn incompatibilities
i can test with my x64 machine if you want. and i think i used the x86 pidgenx.dll in mine and it works fine on a x64 machine
I can't load pidgenx.dll (x86 taken form VAMT) on x64, it this dll from VAMT available in X64 version?
DllImport looks for the dll in the current directory and then in the system directory. You cannot specify the path of the dll, only workaround is to change the current directory. Code: Environment.CurrentDirectory = @"C:\Win7";
new link for the compiled version of my key checker and like before dont complain about it if you dont like it use the online one PIDCHECK ER
To load the dll from dynamic paths you need to call LoadLibrary() from kernel32.dll. Here's the code snippet on how to do it. Code: [DllImport("kernel32", SetLastError = true)] public static extern IntPtr LoadLibrary(string fileName); [DllImport("kernel32", SetLastError = true)] public static extern bool FreeLibrary(IntPtr hModule); [DllImport("pidgenx.dll", EntryPoint = "PidGenX", CharSet = CharSet.Auto)] static extern int PidGenX(string ProductKey, string PkeyPath, string MSPID, int UnknownUsage, IntPtr ProductID, IntPtr DigitalProductID, IntPtr DigitalProductID4); private string CheckProductKey(string ProductKey) { string dllPath = temp + "\\pidgenx.dll"; //temp is the folder path that has the dll and config file IntPtr dllHandle = LoadLibrary(dllPath); . . . string PKeyPath = temp + "\\pkeyconfig.xrm-ms"; . . . Marshal.FreeHGlobal(PID); Marshal.FreeHGlobal(DPID); Marshal.FreeHGlobal(DPID4); bool clear = true; while(clear) //Must be run thrice in order to dereference the pointer clear = FreeLibrary(dllHandle); return result; }
The error occurs when wrong arguments are passed to the unmanaged function. GetProcAddress is used along with Marshal.GetDelegateForFunctionPointer Method. Its an alternative method to DllImport which uses delegates to invoke the function.
You got it to work without this error? weird... u used included VBScript example? (try to run it a few times in a row, after a while i got that error)
I keep getting that error, even when ran from command prompt opened with Administrator privileges, what do OS do you run it on? X64 or X32?
I run it on Vista 32 bit. EDIT: I am using the Visual Studio command Prompt. Checked it in normal command prompt and i get that error too.
i'm @work now, here i have Vista X32 as well, but keep getting the error (@home i had the same issue, although this was X64) You altered the example by any chance? The first key (Win7) is being validated just fine, when it tries to validate the 2nd key (Vista) it fails with the error described using the VAMT pidgenx.dll