-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
87 changed files
with
13,164 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
/*======================================================================================= | ||
OpenNETCF.Desktop.Communication.AutoStartApps | ||
Copyright © 2003, OpenNETCF.org | ||
This library is free software; you can redistribute it and/or modify it under | ||
the terms of the OpenNETCF.org Shared Source License. | ||
This library is distributed in the hope that it will be useful, but | ||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
FITNESS FOR A PARTICULAR PURPOSE. See the OpenNETCF.org Shared Source License | ||
for more details. | ||
You should have received a copy of the OpenNETCF.org Shared Source License | ||
along with this library; if not, email [email protected] to request a copy. | ||
If you wish to contact the OpenNETCF Advisory Board to discuss licensing, please | ||
email [email protected]. | ||
For general enquiries, email [email protected] or visit our website at: | ||
http://www.opennetcf.org | ||
=======================================================================================*/ | ||
using System; | ||
using System.Collections; | ||
|
||
namespace OpenNETCF.Desktop.Communication | ||
{ | ||
/// <summary> | ||
/// Summary description for AutoStart. | ||
/// </summary> | ||
public class AutoStartApps : CollectionBase | ||
{ | ||
private string m_key; | ||
|
||
internal AutoStartApps(string RegKey) | ||
{ | ||
m_key = RegKey; | ||
|
||
string[] vals = null; | ||
try | ||
{ | ||
Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(m_key); | ||
|
||
vals = new string[key.ValueCount]; | ||
string[] names = key.GetValueNames(); | ||
|
||
for(int k = 0 ; k < vals.Length ; k++) | ||
{ | ||
List.Add ((string)key.GetValue(names[k])); | ||
} | ||
|
||
key.Close(); | ||
} | ||
catch(Exception) | ||
{ | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Add a new application to the list of apps to AutoStart | ||
/// </summary> | ||
/// <param name="AppPath">Fully qualified path to app</param> | ||
public void Add(string AppPath) | ||
{ | ||
Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(m_key, true); | ||
|
||
// give the value a random name | ||
key.SetValue(System.Guid.NewGuid().ToString(), AppPath); | ||
|
||
key.Close(); | ||
List.Add(AppPath); | ||
} | ||
|
||
/// <summary> | ||
/// Remove an application from the list of apps to AutoStart | ||
/// </summary> | ||
/// <param name="AppPath">Fully qualified path to app</param> | ||
public void Remove(string AppPath) | ||
{ | ||
Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(m_key, true); | ||
|
||
string[] vals = key.GetValueNames(); | ||
|
||
for(int v = 0 ; v < vals.Length ; v++) | ||
{ | ||
if(string.Compare((string)key.GetValue(vals[v]), AppPath, true) == 0) | ||
{ | ||
key.DeleteValue(vals[v], false); | ||
break; | ||
} | ||
} | ||
|
||
key.Close(); | ||
|
||
List.Remove(AppPath); | ||
} | ||
|
||
/// <summary> | ||
/// Clear all AutoStart apps | ||
/// </summary> | ||
public new void Clear() | ||
{ | ||
Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(m_key, true); | ||
|
||
string[] vals = key.GetValueNames(); | ||
|
||
for(int v = 0 ; v < vals.Length ; v++) | ||
{ | ||
key.DeleteValue(vals[v], false); | ||
} | ||
|
||
key.Close(); | ||
List.Clear(); | ||
} | ||
|
||
/// <summary> | ||
/// Remove an application from the list of apps to AutoStart | ||
/// </summary> | ||
/// <param name="Index">Index of item to remove</param> | ||
public new void RemoveAt(int Index) | ||
{ | ||
string toremove = (string)List[Index]; | ||
|
||
Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(m_key, true); | ||
|
||
string[] vals = key.GetValueNames(); | ||
|
||
for(int v = 0 ; v < vals.Length ; v++) | ||
{ | ||
if(string.Compare((string)key.GetValue(vals[v]), toremove, true) == 0) | ||
{ | ||
key.DeleteValue(vals[v], false); | ||
break; | ||
} | ||
} | ||
|
||
key.Close(); | ||
|
||
List.RemoveAt(Index); | ||
} | ||
|
||
/// <summary> | ||
/// Indexer | ||
/// </summary> | ||
public string this[int index] | ||
{ | ||
get | ||
{ | ||
return (string)List[index]; | ||
} | ||
} | ||
} | ||
} |
116 changes: 116 additions & 0 deletions
116
OpenNETCF.Desktop.Communication/CFPerformanceMonitor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
/*======================================================================================= | ||
OpenNETCF.Desktop.Communication.CFPerformanceMonitor | ||
Copyright © 2003, OpenNETCF.org | ||
This library is free software; you can redistribute it and/or modify it under | ||
the terms of the OpenNETCF.org Shared Source License. | ||
This library is distributed in the hope that it will be useful, but | ||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
FITNESS FOR A PARTICULAR PURPOSE. See the OpenNETCF.org Shared Source License | ||
for more details. | ||
You should have received a copy of the OpenNETCF.org Shared Source License | ||
along with this library; if not, email [email protected] to request a copy. | ||
If you wish to contact the OpenNETCF Advisory Board to discuss licensing, please | ||
email [email protected]. | ||
For general enquiries, email [email protected] or visit our website at: | ||
http://www.opennetcf.org | ||
=======================================================================================*/ | ||
using System; | ||
using System.IO; | ||
|
||
namespace OpenNETCF.Desktop.Communication | ||
{ | ||
/// <summary> | ||
/// This class can be used to generate and capture performance statistics | ||
/// from .NET Compact Framework applications run on a connected device. | ||
/// </summary> | ||
public class CFPerformanceMonitor | ||
{ | ||
PerformanceStatistics m_stats; | ||
RAPI m_rapi; | ||
static string m_perfkey = @"SOFTWARE\Microsoft\.NETCompactFramework\PerfMonitor"; | ||
|
||
internal CFPerformanceMonitor(RAPI rapi) | ||
{ | ||
m_stats = new PerformanceStatistics(); | ||
m_rapi = rapi; | ||
} | ||
|
||
/// <summary> | ||
/// This method informs the device to begin profiling all managed applications | ||
/// </summary> | ||
public void EnableProfiling() | ||
{ | ||
m_rapi.CheckConnection(); | ||
|
||
CERegistryKey key = CERegistry.LocalMachine.CreateSubKey(m_perfkey); | ||
key.SetValue("Counters", 1); | ||
} | ||
|
||
/// <summary> | ||
/// This method informs the device to stop profiling all managed applications | ||
/// </summary> | ||
public void DisableProfiling() | ||
{ | ||
m_rapi.CheckConnection(); | ||
|
||
CERegistryKey key = CERegistry.LocalMachine.CreateSubKey(m_perfkey); | ||
key.SetValue("Counters", 0); | ||
} | ||
|
||
/// <summary> | ||
/// Retrieves the statistics for the last profiled managed application | ||
/// <seealso cref="PerformanceStatistics"/> | ||
/// </summary> | ||
/// <returns>Profile statistics</returns> | ||
public PerformanceStatistics GetCurrentStatistics() | ||
{ | ||
m_rapi.CheckConnection(); | ||
GetStats(); | ||
|
||
return m_stats; | ||
} | ||
|
||
private void GetStats() | ||
{ | ||
string localpath = System.Windows.Forms.Application.StartupPath + "\\mscoree.stat"; | ||
string line; | ||
|
||
m_rapi.CopyFileFromDevice("\\mscoree.stat", localpath, true); | ||
|
||
StreamReader reader = System.IO.File.OpenText(localpath); | ||
|
||
line = reader.ReadLine(); | ||
|
||
while(line != null) | ||
{ | ||
// there are a couple blank lines | ||
if(line.Length > 1) | ||
{ | ||
// skip the "header" line | ||
if(line.Substring(0, 7) != "counter") | ||
{ | ||
// get name | ||
string name = line.Substring(0, 47).Trim(); | ||
int val = Convert.ToInt32(line.Substring(46, 11).Trim(), 10); | ||
int samples = Convert.ToInt32(line.Substring(57, 9).Trim(), 10); | ||
int mean = Convert.ToInt32(line.Substring(66, 9).Trim(), 10); | ||
int min = Convert.ToInt32(line.Substring(75, 9).Trim(), 10); | ||
int max = Convert.ToInt32(line.Substring(84, 9).Trim(), 10); | ||
|
||
m_stats.Add(new PerformanceStatistic(name, val, samples, mean, min, max)); | ||
} | ||
} | ||
line = reader.ReadLine(); | ||
} | ||
reader.Close(); | ||
File.Delete(localpath); | ||
} | ||
} | ||
} |
120 changes: 120 additions & 0 deletions
120
OpenNETCF.Desktop.Communication/Classes/FileInformation.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace OpenNETCF.Desktop.Communication | ||
{ | ||
[StructLayout(LayoutKind.Explicit, CharSet = CharSet.Unicode)] | ||
public struct FileInformation //CE_FIND_DATA | ||
{ | ||
[FieldOffset(0), MarshalAs(UnmanagedType.U4)] | ||
public UInt32 dwFileAttributes; | ||
[FieldOffset(4)] | ||
public FILETIME ftCreationTime; | ||
[FieldOffset(12)] | ||
public FILETIME ftLastAccessTime; | ||
[FieldOffset(20)] | ||
public FILETIME ftLastWriteTime; | ||
[FieldOffset(28), MarshalAs(UnmanagedType.U4)] | ||
public UInt32 nFileSizeHigh; | ||
[FieldOffset(32), MarshalAs(UnmanagedType.U4)] | ||
public UInt32 nFileSizeLow; | ||
[FieldOffset(36), MarshalAs(UnmanagedType.U4)] | ||
public UInt32 dwOID; | ||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260), FieldOffset(40)] | ||
public string FileName; | ||
}; | ||
|
||
/* | ||
/// <summary> | ||
/// This structure describes a file found by the FindFirstFile or FindNextFile. | ||
/// </summary> | ||
/// <seealso cref="M:OpenNETCF.Desktop.Communication.RAPI.EnumFiles(System.String@)"/> | ||
public class FileInformation //WIN32_FIND_DATA | ||
{ | ||
private byte[] data; | ||
public FileInformation() | ||
{ | ||
data = new byte[592]; | ||
} | ||
/// <summary> | ||
/// Byte representation of FileInformation | ||
/// </summary> | ||
public static implicit operator byte[](FileInformation fi) | ||
{ | ||
return fi.data; | ||
} | ||
/// <summary> | ||
/// File attributes of the file found. | ||
/// </summary> | ||
public int FileAttributes | ||
{ | ||
get | ||
{ | ||
return BitConverter.ToInt32(data, 0); | ||
} | ||
} | ||
/// <summary> | ||
/// UTC time at which the file was created. | ||
/// </summary> | ||
public DateTime CreateTime | ||
{ | ||
get | ||
{ | ||
long time = BitConverter.ToInt64(data, 4); | ||
return DateTime.FromFileTime(time); | ||
} | ||
} | ||
/// <summary> | ||
/// UTC time at which the file was last accessed. | ||
/// </summary> | ||
public DateTime LastAccessTime | ||
{ | ||
get | ||
{ | ||
long time = BitConverter.ToInt64(data, 12); | ||
return DateTime.FromFileTime(time); | ||
} | ||
} | ||
/// <summary> | ||
/// UTC time at which the file was modified. | ||
/// </summary> | ||
public DateTime LastWriteTime | ||
{ | ||
get | ||
{ | ||
long time = BitConverter.ToInt64(data, 20); | ||
return DateTime.FromFileTime(time); | ||
} | ||
} | ||
/// <summary> | ||
/// Size, in bytes, of file | ||
/// </summary> | ||
public long FileSize | ||
{ | ||
get | ||
{ | ||
return BitConverter.ToInt32(data, 28) + (BitConverter.ToInt32(data, 32) << 32); | ||
} | ||
} | ||
/// <summary> | ||
/// Full name of the file | ||
/// </summary> | ||
public string FileName | ||
{ | ||
get | ||
{ | ||
return Encoding.Unicode.GetString(data, 40, 256).TrimEnd('\0'); | ||
} | ||
} | ||
}*/ | ||
} |
Oops, something went wrong.