Einstiegspunkt wird nicht gefunden
-
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Runtime.InteropServices; namespace WindowsApplication2 { public partial class Form3 : Form { public const short FILE_ATTRIBUTE_NORMAL = 0x80; public const short INVALID_HANDLE_VALUE = -1; public const uint GENERIC_READ = 0x80000000; public const uint GENERIC_WRITE = 0x40000000; public const short CREATE_NEW = 1; public const short CREATE_ALWAYS = 2; public const short OPEN_EXISTING = 3; public const short ERROR_FILE_EXISTS = 80; public const short ERROR_INVALID_PARAMETER = 87; public const short ERROR_DISK_FULL = 112; [StructLayout(LayoutKind.Sequential)] public struct OSVERSIONINFO { public int dwOSVersionInfoSize; public int dwMajorVersion; public int dwMinorVersion; public int dwBuildNumber; public int dwPlatformId; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] public string szCSDVersion; } [StructLayout(LayoutKind.Sequential, Pack = 4)] public struct SYSTEM_POWER_STATUS_EX { internal byte ACLineStatus; internal byte BatteryFlag; internal byte BatteryLifePercent; internal byte Reserved1; internal uint BatteryLifeTime; internal uint BatteryFullLifeTime; internal byte Reserved2; internal byte BackupBatteryFlag; internal byte BackupBatteryLifePercent; internal byte Reserved3; internal uint BackupBatteryLifeTime; internal uint BackupBatteryFullLifeTime; } [StructLayout(LayoutKind.Sequential)] public struct MEMORYSTATUS { internal int dwLength; internal int dwMemoryLoad; internal int dwTotalPhys; internal int dwAvailPhys; internal int dwTotalPageFile; internal int dwAvailPageFile; internal int dwTotalVirtual; internal int dwAvailVirtual; } [StructLayout(LayoutKind.Sequential)] public struct RAPIINIT { int cbSize; int heRapiInit; int hrRapiInit; } [StructLayout(LayoutKind.Sequential)] public struct SECURITY_ATTRIBUTES { public int nLength; public int lpSecurityDescriptor; public int bInheritHandle; } [DllImport("rapi.dll", CharSet = CharSet.Unicode)] public static extern int CeCloseHandle(int hObject); [DllImport("rapi.dll", CharSet = CharSet.Unicode)] public static extern int CeCreateFile(string lpFileName, uint dwDesiredAccess, int dwShareMode, int lpSecurityAttributes, int dwCreationDisposition, int dwFlagsAndAttributes, int hTemplateFile); [DllImport("rapi.dll", CharSet = CharSet.Unicode)] public static extern int CeRapiInitEx([MarshalAs(UnmanagedType.Struct)] ref RAPIINIT pRapiInit); [DllImport("rapi.dll", CharSet = CharSet.Unicode)] public static extern int CeRapiInit(); [DllImport("rapi.dll", CharSet = CharSet.Unicode)] public static extern int CeRapiUninit(); [DllImport("rapi.dll", CharSet = CharSet.Unicode)] public static extern int CeReadFile(int hFile, StringBuilder lpBuffer, int nNumberOfbytesToRead, out int lpNumberOfbytesRead, int lpOverlapped); [DllImport("rapi.dll", CharSet = CharSet.Unicode)] public static extern int CeWriteFile(int hFile, StringBuilder lpBuffer, int nNumberOfbytesToWrite, out int lpNumberOfbytesWritten, int lpOverlapped); [DllImport("rapi.dll", CharSet = CharSet.Unicode)] public static extern int GetLastError(); [DllImport("rapi.dll", CharSet = CharSet.Unicode)] static extern int CeSetEndOfFile(int hFile); [DllImport("rapi.dll", CharSet = CharSet.Unicode)] public static extern int CeGetFileSize(int hFile, int lpFileSizeHigh); [DllImport("rapi.dll", CharSet = CharSet.Unicode)] public static extern int CeGetLastError(); [DllImport("rapi.dll", CharSet = CharSet.Unicode)] public static extern Boolean CeGetVersionEx([MarshalAs(UnmanagedType.Struct)] ref OSVERSIONINFO lpVersionInformation); [DllImport("rapi.dll", CharSet = CharSet.Unicode)] static extern bool CeGetSystemPowerStatusEx(ref SYSTEM_POWER_STATUS_EX ps, bool update); [DllImport("rapi.dll", CharSet = CharSet.Unicode)] public static extern Boolean CeGetSystemPowerStatusEx([MarshalAs(UnmanagedType.Struct)] ref SYSTEM_POWER_STATUS_EX lpSystemPowerStatusInformation); [DllImport("rapi.dll", CharSet = CharSet.Unicode)] static extern bool CeGlobalMemoryStatus(ref MEMORYSTATUS mst, bool update); [DllImport("rapi.dll", CharSet = CharSet.Unicode)] public static extern Boolean CeGlobalMemoryStatus([MarshalAs(UnmanagedType.Struct)] ref MEMORYSTATUS lpmst); public Form3() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { OSVERSIONINFO ceVersion = new OSVERSIONINFO(); ceVersion.dwOSVersionInfoSize = 276; CeRapiInit(); if (CeGetVersionEx(ref ceVersion)) { label2.Text = ceVersion.dwMajorVersion.ToString()+"."+ceVersion.dwMinorVersion.ToString()+"."+ceVersion.dwBuildNumber.ToString(); label6.Text = ceVersion.dwPlatformId.ToString(); if (ceVersion.dwPlatformId == 0) { label6.Text = "Windows (32 Bit)s"; } else if (ceVersion.dwPlatformId == 1) { label6.Text = "Windows (32 Bit)Windows"; } else if (ceVersion.dwPlatformId == 2) { label6.Text = "Windows (32 Bit) NT"; } else if (ceVersion.dwPlatformId == 3) { label6.Text = "Windows (32 Bit) CE"; } } SYSTEM_POWER_STATUS_EX ceSystemPowerStatus = new SYSTEM_POWER_STATUS_EX(); ceSystemPowerStatus.BatteryFlag = 1; ceSystemPowerStatus.ACLineStatus = 1; CeRapiInit(); if (CeGetSystemPowerStatusEx(ref ceSystemPowerStatus, true)) { if (ceSystemPowerStatus.BatteryFlag == 1) { pictureBox1.Show(); label19.Show(); } else if (ceSystemPowerStatus.BatteryFlag == 2) { pictureBox2.Show(); label20.Show(); } else if (ceSystemPowerStatus.BatteryFlag == 4) { pictureBox3.Show(); label21.Show(); } else if (ceSystemPowerStatus.BatteryFlag == 8) { pictureBox4.Show(); label22.Show(); } else if (ceSystemPowerStatus.BatteryFlag == 128) { label3.Text = "keine Battery"; } else if (ceSystemPowerStatus.BatteryFlag == 255) { label3.Text = "unbekannter Status"; } if (ceSystemPowerStatus.ACLineStatus == 0) { label4.Text = "Offline"; } else if (ceSystemPowerStatus.ACLineStatus == 1) { label4.Text = "Online"; } else if (ceSystemPowerStatus.ACLineStatus == 255) { label4.Text = "unbekannter Status"; } label26.Text = ceSystemPowerStatus.BatteryLifePercent.ToString() + "%"; } MEMORYSTATUS CeGlobalMemoryStatus = new MEMORYSTATUS(); CeGlobalMemoryStatus.dwLength = 5; CeRapiInit(); if (CeMemoryStatus(ref CeGlobalMemoryStatus)) { label12.Text = CeGlobalMemoryStatus.dwLength.ToString(); } } private void button2_Click(object sender, EventArgs e) { Close(); } private void gbVersion_Enter(object sender, EventArgs e) { } private void button1_Click_1(object sender, EventArgs e) { } private void Form3_Load(object sender, EventArgs e) { } private void pictureBox1_Click(object sender, EventArgs e) { } private void groupBox1_Enter(object sender, EventArgs e) { } } public partial class ramiimport { } }
Angezeigter Fehler: Der Name "CeMemoryStatus" ist im aktuellen Kontext nicht vorhanden.
Kann das Bitte jem. berichtigen!?
-
Kannst Du das Ganze bitte auf die relevanten Codeausschnitte kürzen?
-
Ja, kann ich!
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Runtime.InteropServices; namespace WindowsApplication2 { public partial class Form3 : Form { public const short FILE_ATTRIBUTE_NORMAL = 0x80; public const short INVALID_HANDLE_VALUE = -1; public const uint GENERIC_READ = 0x80000000; public const uint GENERIC_WRITE = 0x40000000; public const short CREATE_NEW = 1; public const short CREATE_ALWAYS = 2; public const short OPEN_EXISTING = 3; public const short ERROR_FILE_EXISTS = 80; public const short ERROR_INVALID_PARAMETER = 87; public const short ERROR_DISK_FULL = 112; [StructLayout(LayoutKind.Sequential)] public struct OSVERSIONINFO { public int dwOSVersionInfoSize; public int dwMajorVersion; public int dwMinorVersion; public int dwBuildNumber; public int dwPlatformId; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] public string szCSDVersion; } [StructLayout(LayoutKind.Sequential, Pack = 4)] public struct SYSTEM_POWER_STATUS_EX { internal byte ACLineStatus; internal byte BatteryFlag; internal byte BatteryLifePercent; internal byte Reserved1; internal uint BatteryLifeTime; internal uint BatteryFullLifeTime; internal byte Reserved2; internal byte BackupBatteryFlag; internal byte BackupBatteryLifePercent; internal byte Reserved3; internal uint BackupBatteryLifeTime; internal uint BackupBatteryFullLifeTime; } [StructLayout(LayoutKind.Sequential)] public struct MEMORYSTATUS { internal int dwLength; internal int dwMemoryLoad; internal int dwTotalPhys; internal int dwAvailPhys; internal int dwTotalPageFile; internal int dwAvailPageFile; internal int dwTotalVirtual; internal int dwAvailVirtual; } [StructLayout(LayoutKind.Sequential)] public struct RAPIINIT { int cbSize; int heRapiInit; int hrRapiInit; } [StructLayout(LayoutKind.Sequential)] public struct SECURITY_ATTRIBUTES { public int nLength; public int lpSecurityDescriptor; public int bInheritHandle; } [DllImport("rapi.dll", CharSet = CharSet.Unicode)] public static extern int CeCloseHandle(int hObject); [DllImport("rapi.dll", CharSet = CharSet.Unicode)] public static extern int CeCreateFile(string lpFileName, uint dwDesiredAccess, int dwShareMode, int lpSecurityAttributes, int dwCreationDisposition, int dwFlagsAndAttributes, int hTemplateFile); [DllImport("rapi.dll", CharSet = CharSet.Unicode)] public static extern int CeRapiInitEx([MarshalAs(UnmanagedType.Struct)] ref RAPIINIT pRapiInit); [DllImport("rapi.dll", CharSet = CharSet.Unicode)] public static extern int CeRapiInit(); [DllImport("rapi.dll", CharSet = CharSet.Unicode)] public static extern int CeRapiUninit(); [DllImport("rapi.dll", CharSet = CharSet.Unicode)] public static extern int CeReadFile(int hFile, StringBuilder lpBuffer, int nNumberOfbytesToRead, out int lpNumberOfbytesRead, int lpOverlapped); [DllImport("rapi.dll", CharSet = CharSet.Unicode)] public static extern int CeWriteFile(int hFile, StringBuilder lpBuffer, int nNumberOfbytesToWrite, out int lpNumberOfbytesWritten, int lpOverlapped); [DllImport("rapi.dll", CharSet = CharSet.Unicode)] public static extern int GetLastError(); [DllImport("rapi.dll", CharSet = CharSet.Unicode)] static extern int CeSetEndOfFile(int hFile); [DllImport("rapi.dll", CharSet = CharSet.Unicode)] public static extern int CeGetFileSize(int hFile, int lpFileSizeHigh); [DllImport("rapi.dll", CharSet = CharSet.Unicode)] public static extern int CeGetLastError(); [DllImport("rapi.dll", CharSet = CharSet.Unicode)] public static extern Boolean CeGetVersionEx([MarshalAs(UnmanagedType.Struct)] ref OSVERSIONINFO lpVersionInformation); [DllImport("rapi.dll", CharSet = CharSet.Unicode)] static extern bool CeGetSystemPowerStatusEx(ref SYSTEM_POWER_STATUS_EX ps, bool update); [DllImport("rapi.dll", CharSet = CharSet.Unicode)] public static extern Boolean CeGetSystemPowerStatusEx([MarshalAs(UnmanagedType.Struct)] ref SYSTEM_POWER_STATUS_EX lpSystemPowerStatusInformation); [DllImport("rapi.dll", CharSet = CharSet.Unicode)] public static extern Boolean CeMemoryStatus([MarshalAs(UnmanagedType.Struct)] ref MEMORYSTATUS lpmst);
MEMORYSTATUS CeGlobalMemoryStatus = new MEMORYSTATUS(); CeGlobalMemoryStatus.dwLength = 5; CeRapiInit(); if (CeMemoryStatus(ref CeGlobalMemoryStatus)) { label12.Text = CeGlobalMemoryStatus.dwLength.ToString(); }
-
Das Problem ist, der Einstiegspunkt CeMemoryStatus wurde nicht in der DLL rapi.dll gefunden.
-
Mir ist keine RAPI-Funktion namens CeMemoryStatus bekannt. Meinst du CeGlobalMemoryStatus?
-
Wurde schon geklärt und geschlossen!