Page 1 of 1

Autohotkey新版编译不正常,使用旧版本编译正常,求助help me~!

Posted: 16 May 2016, 10:49
by derQiQ
在1.1.23.06版本中。调试运行显示数值是正常的,可是编译之后就显示数值为0了。(测试系统Win7_32,WinXP_32)


而使用1.1.07.03编译就正常显示数值。

Code: Select all

;显示系统缓存工作集当前值Start=========================================
; Constant
SYSTEM_INFO_CLASS = 0x15

; Set buffer size
SystemInfoLength = 36
VarSetCapacity(SystemCacheInfo, SystemInfoLength, 0)		

; DLL call
DllCall("C:\Windows\system32\ntdll.dll\NtQuerySystemInformation",  "UInt",SYSTEM_INFO_CLASS,  "UInt",&SystemCacheInfo,  "UInt",SystemInfoLength)

; Read values
CurrentSize := NumGet(SystemCacheInfo, 0, "UInt")
PeakSize := NumGet(SystemCacheInfo, 4, "UInt")
PageFaultCount := NumGet(SystemCacheInfo, 8, "UInt")
MinimumWorkingSet := NumGet(SystemCacheInfo, 12, "UInt")
MaximumWorkingSet := NumGet(SystemCacheInfo, 16, "UInt")
TransitionSharedPages := NumGet(SystemCacheInfo, 20, "UInt")
PeakTransitionSharedPages := NumGet(SystemCacheInfo, 24, "UInt")

; Tweak values to make correct
CurrentSize /= 1024
PeakSize /= 1024
MinimumWorkingSet *= 4
MaximumWorkingSet *= 4
TransitionSharedPages *= 4
PeakTransitionSharedPages *= 4
	
;统计系统缓存工作集当前值End==============================================
	

	start:
;gui,Destroy
;gui,new
vMyLV=0
Loop
{





;MsgBox,,,vMyLV=%vMyLV%
if vMyLV=0
Gui, Add, ListView, x0 y0 r45 w400 h550 vMyLV, Attribute|Value
GuiControl, -Redraw, MyLV 

;While colItems[objItem]
;{
  ;/*
  ;aaa:=objItem.Name
  ;if aaa=_Total
	;{
  LV_Add("","CacheBytes: " ,CurrentSize)
  LV_Add("","CacheBytesPeak: " ,PeakSize)
  LV_Add("","MinimumWorkingSet: " ,MinimumWorkingSet)
    LV_Add("","PageFaultCount : " ,PageFaultCount )
    LV_Add("","MaximumWorkingSet: " ,MaximumWorkingSet)
	LV_Add("","TransitionSharedPages: " ,TransitionSharedPages)
	LV_Add("","PeakTransitionSharedPages: " ,PeakTransitionSharedPages)

  ;bbb:=objItem.AvgDiskQueueLength  
  ;LV_Add("","aaa: " ,aaa)
  ;LV_Add("","bbb: " ,bbb)
	;}
;}

GuiControl, +Redraw, MyLV 
LV_ModifyCol()
vMyLV=1
Gui, Show, y150 w400 h550, Operating System 内存相关信息 ;Operating System Details
Sleep 2000
LV_Delete()
Gui, Show  ;, y150 w400 h550, Operating System Details
;Sleep 100
}
;Return

GuiClose:
;Return
ExitApp
;goto start

*/


Re: Autohotkey新版编译不正常,使用旧版本编译正常,求助help me~!

Posted: 17 May 2016, 01:01
by jNizM
See my examples for how to use NtQuerySystemInformation:
- NtQuerySystemInformation - CPU Usage
- NtQuerySystemInformation - DiskIO Stats

Code: Select all

NtQuerySystemInformation()    ; http://msdn.com/library/ms724509(vs.85,en-us)
{
    static hModule := DllCall("LoadLibrary", "Str", "ntdll.dll", "Ptr")
    static SYSTEM_INFORMATION_CLASS := 0x15    ; SYSTEM_FILECACHE_INFORMATION
    size := VarSetCapacity(buf, 0, 0)
    DllCall("ntdll\NtQuerySystemInformation", "Int", SYSTEM_INFORMATION_CLASS, "Ptr", &buf, "UInt", 0, "UInt*", size)
    size := VarSetCapacity(buf, size, 0)
    if (DllCall("ntdll\NtQuerySystemInformation", "Int", SYSTEM_INFORMATION_CLASS, "Ptr", &buf, "UInt", size, "UInt*", 0) != 0)
        return "*" ErrorLevel
    Cache := {}
    Cache.CurrentSize                           := NumGet(buf,  o := 0, "UPtr")
    Cache.PeakSize                              := NumGet(buf,  o += A_PtrSize, "UPtr")
    Cache.PageFaultCount                        := NumGet(buf,  o += A_PtrSize, "UInt")
    Cache.MinimumWorkingSet                     := NumGet(buf,  o += A_PtrSize, "UPtr")
    Cache.MaximumWorkingSet                     := NumGet(buf,  o += A_PtrSize, "UPtr")
    Cache.CurrentSizeIncludingTransitionInPages := NumGet(buf,  o += A_PtrSize, "UPtr")
    Cache.PeakSizeIncludingTransitionInPages    := NumGet(buf,  o += A_PtrSize, "UPtr")
    Cache.TransitionRePurposeCount              := NumGet(buf,  o += A_PtrSize, "UInt")
    Cache.Flags                                 := NumGet(buf,  o += 4, "UInt")
    return Cache
}

FileCache := NtQuerySystemInformation()

MsgBox % "CurrentSize:`t`t`t"                       FileCache.CurrentSize "`n"
       . "PeakSize:`t`t`t`t"                        FileCache.PeakSize "`n"
       . "PageFaultCount:`t`t`t"                    FileCache.PageFaultCount "`n"
       . "MinimumWorkingSet:`t`t"                   FileCache.MinimumWorkingSet "`n"
       . "MaximumWorkingSet:`t`t"                   FileCache.MaximumWorkingSet "`n"
       . "CurrentSizeIncludingTransitionInPages:`t" FileCache.CurrentSizeIncludingTransitionInPages "`n"
       . "PeakSizeIncludingTransitionInPages:`t"    FileCache.PeakSizeIncludingTransitionInPages "`n"
       . "TransitionRePurposeCount:`t`t"            FileCache.TransitionRePurposeCount "`n"
       . "Flags:`t`t`t`t"                           FileCache.Flags


; ==================================================================================================

/*
typedef struct _SYSTEM_FILECACHE_INFORMATION         
{                                                    
    SIZE_T CurrentSize;
    SIZE_T PeakSize;
    ULONG  PageFaultCount;
    SIZE_T MinimumWorkingSet;
    SIZE_T MaximumWorkingSet;
    SIZE_T CurrentSizeIncludingTransitionInPages;
    SIZE_T PeakSizeIncludingTransitionInPages;
    ULONG  TransitionRePurposeCount;
    ULONG  Flags;
} SYSTEM_FILECACHE_INFORMATION;

32-bit sizeof( 4 + 4 + 4               + 4 + 4 + 4 + 4 + 4 + 4 ) => 36 bytes
64-bit sizeof( 8 + 8 + 4 + 4 (padding) + 8 + 8 + 8 + 8 + 4 + 4 ) => 64 bytes
*/

Re: Autohotkey新版编译不正常,使用旧版本编译正常,求助help me~!

Posted: 17 May 2016, 03:02
by derQiQ
这段代码在Win7_32下是正常的,但到了WinXP_32下就不正常了。
还有前面我想表达的是,1.1.23.06新版本编译与调试得到的结果为什么不同? 而1.1.07.03旧版本得到的结果都是一致的。

This code in the Win7_32 is normal, but under the WinXP_32 is not normal.
And what I want to express in front of the new version of the 1.1.23.06 compiler and the results of the test is different? The results are consistent with the old version of 1.1.07.03.
(language from Machine Translation)