I downloaded the ATI AGS (High-Speed GPU) Libri, and retrieved some basic driver information using this API I am trying to do C#. The ATI AGS Library is available for download from here:
I have written a bit of the C # code to draw driver information from the GPU using the AGS API, but I am having some problem called unmanaged method. I have tried all types of different types of DllImportAttribute parameters, no avail. I am either receiving a Marshal Directive Expression or Pewwock Stack Embellishment.
I am sure that all these are due to wrong p / applicants, but I have terminated my knowledge of this API. By the way, on one hand, you will see that I am using 32-bit DLL, and I think it's going to move forward, but when I use 64-bit DLL Give me a BadImageFormatException.
Here is the code I am using:
[DllImport ("atiags.dll", securely = false, exact spelling = true, throenanaplexical = true, charset = CharSet.Unicode, EntryPoint = "agsDriverGetVersionInfo")] Public stable extern zero agsDriverGetVersionInfo ([MarshalAs (UnmanagedType.Struct)] agsDriverVersionInfoStruct DriverInfo; Public stable agsDriverVersionInfoStruct GetAgsDriverVersion () {agsDriverVersionInfoStruct DriverInfo = new agsDriverVersionInfoStruct (); AgsDriverGetVersionInfo (DriverInfo out); } Public Structure AggregarianVarsion Infrastruct [[Marshall AS (Unmanaged Type. LPTST)] Public String StradyWarson; [Marshall (UnmanagedType.LPStr)] Public string strCatalystVersion; [Marshall (UnmanagedType.LPStr)] Public string strCatalystWebLink; }
Any thoughts?
EDIT: Here is the definition of the ATIAGSDriverGetVersionInfo () function at ati_ags.h. According to the ATI AGS documentation (PDF included in the download), it asks to define _ATI_AGS_USE_DLL, so I added this line to the top of my C # class code file:
Documentation quotation
Determine if the functionality of AGS will be accessed through a DLL or static lib, if the dll option is selected, define _ATI_AGS_USE_DLL in its project properties Do Uniscit. If a static BB option is selected, then a special token should not be defined.
__Inline AGSRTranscodeAtiAdsDriverGuiterWindowsInfo (AGSDriverWarsian Infostrons * LPDrvVersion Info) {AGSRTernCold iReturnValue = AGS_SUCCESS; // Validate parameter if (NULL == lpDriverVersionInfo) {return AGS_FAILURE; } #ifdef _ATI_AGS_USE_DLL // Load loading loading lib = NULL; Lib = LoadLibrary (TEXT ("atiags.dll")); If (NULL == lib) {lib = LoadLibrary (TEXT ("atiags64.dll")); If (Nal == Lib) {return AGS_FAILURE; }} // function pointer AGSDRIVERGETVERSIONINFO agsDriverGetVersionInfo = NULL; AgsDriverGetVersionInfo = (AGSDRIVERGETVERSIONINFO) GetProcAddress (lib, "agsDriverGetVersionInfo"); If (NULL == agsDriverGetVersionInfo) {Free Library (Lib); Return AGS_FAILURE; } #endif // _ATI_AGS_USE_DLL // Get the number of GPUs iReturnValue = agsDriverGetVersionInfo (lpDriverVersionInfo); #ifdef _ATI_AGS_USE_DLL // Free Free Lib Freelibari (Lib); #endif // _ATI_AGS_USE_DLL Return iReturnValue; }
This is the trick for me ...
public Code AGSDriverVersionInfoStruct {[MarshmanAs (UnmanagedType.ByValTStr, SizeConst = 256)] Public string strDriverVersion; [Marshall (UnmanagedType.ByValTStr, SizeConst = 256)] Public string strCatalystVersion; [Marshall (UnmanagedType.ByValTStr, SizeConst = 256)] Public string strCatalystWebLink; } Public Static Class AGSharp {[DllImport ("atiags.dll", Calling Convention = Calling Convention. CDEcl, EntryPoint = "agsDriverGetVersionInfo")) Public Static Extern AGSReturnCode agsDriverGetVersionInfo (outside AGSDriverVersionInfoStruct driver_info); }
... It seems that there was a problem in the wrong calling conference (as Richard had already told)
Comments
Post a Comment