Hi,
ich versuche gerade mich mit DllStructCreate() und DLLCall() zu beschäfftigen, weil ich kein Plan von der Sache habe.
Als Übung wollte ich die DLL GetCoreTempInfo.dll laden und die Werte entsprechend herauslesen.
Da ich auch noch keine Ahnung von C/C++ habe, ist der Versuch natürlich misslungen:
Spoiler anzeigen
#cs
Shared memory implementation in Core Temp:
Core Temp shares the following structure:
[/autoit] [autoit][/autoit] [autoit]typedef struct core_temp_shared_data
{
unsigned int uiLoad[256];
unsigned int uiTjMax[128];
unsigned int uiCoreCnt;
unsigned int uiCPUCnt;
float fTemp[256];
float fVID;
float fCPUSpeed;
float fFSBSpeed;
float fMultipier;
char sCPUName[100];
unsigned char ucFahrenheit;
unsigned char ucDeltaToTjMax;
}CORE_TEMP_SHARED_DATA,*PCORE_TEMP_SHARED_DATA,**PPCORE_TEMP_SHARED_DATA;
unsigned int is a 32bit unsigned integer.
unsigned char is 8bit (1 byte) in size.
ucFahrenheit and ucDeltaToTjMax represent boolean values. 0 = false, 1 = true.
If ucFahrenheit is set, the temperature is reported in Fahrenheit.
If ucDeltaToTjMax is set, the temperature reported respresents the distance from TjMax.
Core Temp's shared area is named: "CoreTempMappingObject".
[/autoit] [autoit][/autoit] [autoit]C++ Dynamic Link Library:
[/autoit] [autoit][/autoit] [autoit]This DLL was written in C++, and it can be easily used with most programming languages.
There is only a single function. Here is the internal function declaration:
bool __declspec(dllimport) fnGetCoreTempInfo(CORE_TEMP_SHARED_DATA *&pData);
[/autoit] [autoit][/autoit] [autoit]You can declare it in your program in the following manner:
[/autoit] [autoit][/autoit] [autoit]typedef bool (*fnGetCoreTempInfo)(CORE_TEMP_SHARED_DATA *&pData);
fnGetCoreTempInfo GetCoreTempInfo;
For compatibility with some programming languages a function was added.
It uses Win32 API calling convention and is declared as follows:
bool WINAPI fnGetCoreTempInfoAlt(CORE_TEMP_SHARED_DATA *pData);
[/autoit] [autoit][/autoit] [autoit]typedef bool (*fnGetCoreTempInfoAlt)(CORE_TEMP_SHARED_DATA *pData);
fnGetCoreTempInfoAlt GetCoreTempInfo;
Usage:
[/autoit] [autoit][/autoit] [autoit]* Declare a pointer to CORE_TEMP_SHARED_DATA structure and allocate it.
It is also recommended to fill the allocated memory with NULL to avoid possible problems.
* Call the function using the pointer to CORE_TEMP_SHARED_DATA structure as an argument.
The function will fill the structure if the shared memory was successfully read.
* The function returns 'true' if succeeded and 'false' if it failed. You can use GetLastError() in case the function fails.
* In case the function fails due to an exception GetLastError() returns UNKNOWN_EXCEPTION (0x20000000)
#ce
$CORE_TEMP_SHARED_DATA = DllStructCreate("uint uiLoad[256];uint uiTjMax[128];uint uiCoreCnt;uint uiCPUCnt;float fTemp[256];float fVID;float fCPUSpeed;float fFSBSpeed;float fMultipier;char sCPUName[100];uchar ucFahrenheit;uchar ucDeltaToTjMax")
$call = DllCall("GetCoreTempInfo.dll", "ptr", DllStructGetPtr($CORE_TEMP_SHARED_DATA))
ConsoleWrite(@error & @CRLF)
MsgBox(0,"DllStruct","Struct Size: " & DllStructGetSize($CORE_TEMP_SHARED_DATA) & @CRLF & _
"Struct pointer: " & DllStructGetPtr($CORE_TEMP_SHARED_DATA) & @CRLF & _
"Data:" & @CRLF & _
DllStructGetData($CORE_TEMP_SHARED_DATA,1) & @CRLF & _
DllStructGetData($CORE_TEMP_SHARED_DATA,2) & @CRLF & _
DllStructGetData($CORE_TEMP_SHARED_DATA,3) & @CRLF & _
DllStructGetData($CORE_TEMP_SHARED_DATA,4))
$CORE_TEMP_SHARED_DATA = 0
Ich bekomme als Error 3 zurück, wenn ich die DLL aufrufe (kann die Funktion in der DLL nicht finden)!
Bitte um Hilfe!
DANKE,
UEZ