Fehler in Structure Verfasst am: 19.03.2009, 11:23
In folgenden Code meldet cscript auf einem Windows 2003 Server (SP2) einen Fehler beim ersten 'As':
>Option Explicit
>
>Private Structure MEMORYSTATUS
> Public dwLength As Long
> Public dwMemoryLoad As Long
> Public dwTotalPhys As Long
> Public dwAvailPhys As Long
> Public dwTotalPageFile As Long
> Public dwAvailPageFile As Long
> Public dwTotalVirtual As Long
> Public dwAvailVirtual As Long
>End Structure
>'Deklaration: Globale Form API-Funktionen
>Private Declare Sub GlobalMemoryStatus Lib "kernel32" (lpBuffer As MEMORYSTATUS)
>
>Private Sub Form_Load()
> 'Deklaration: Lokale Prozedur-Variablen
> Dim strText As String
> Dim udtMem As MEMORYSTATUS
> GlobalMemoryStatus udtMem
> With udtMem
> strText = strText & "Speicher belegt in Prozent : " & _
> Format$(.dwMemoryLoad, "@@@@@@@@@@@") & vbCrLf & vbCrLf
> strText = strText & "Totaler physischer Speicher : " & _
> Format$(.dwTotalPhys, "@@@@@@@@@@@") & vbCrLf
> strText = strText & "Davon noch frei : " & _
> Format$(.dwAvailPhys, "@@@@@@@@@@@") & vbCrLf & vbCrLf
> strText = strText & "Bytes in gepageten Dateien : " & _
> Format$(.dwTotalPageFile, "@@@@@@@@@@@") & vbCrLf
> strText = strText & "Davon noch frei : " & _
> Format$(.dwAvailPageFile, "@@@@@@@@@@@") & vbCrLf & vbCrLf
> strText = strText & "Totaler virtueller Speicher : " & _
> Format$(.dwTotalVirtual, "@@@@@@@@@@@") & vbCrLf
> strText = strText & "Davon noch frei : " & _
> Format$(.dwAvailVirtual, "@@@@@@@@@@@") & vbCrLf
> End With
> Label1.Caption = strText
>End Sub
D:\pdfs>cscript MemStatus.vbs
Microsoft (R) Windows Script Host, Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. Alle Rechte vorbehalten.
D:\pdfs\MemStatus.vbs(15, 19) Kompilierungsfehler in Microsoft VBScript: Anweisungsende erwartet
Ich habe sonst nicht viel mit Windows-Programmierung zu tun, aber in diesem Fall versuche ich mit diesem Programm einem Speicherleck eines anderen Programmes auf die Spur zu kommen, Änderungen in diesem Script sind noch nötig.
Kann mir jemand helfen?
christian _________________
ZiuX « Moderator »
Anmeldedatum: 02.05.2008 Beiträge: 160
Verfasst am: 19.03.2009, 23:40
ist das VBS ? Oo
Naja, warum werden die Variablen als Public deklariert? _________________ ziux[ät]jabber.ccc.de
Z1uX.cn
wesselch Newbie
Anmeldedatum: 19.03.2009 Beiträge: 2
Verfasst am: 20.03.2009, 09:58
Ich hab es auch mit Private und mit Dim versucht, mit dem gleichen Resultat.
VBS ist richtig.
Am Ende das Tages soll mir das Programm die bestehende Speicherauslastung auf 'Knopfdruck' liefern.