|
Just tried this and it didn't work. Sorry.
|
|
|
|
|
ya, I donno
google hasn't yielded any results either
|
|
|
|
|
[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr GetWindow(IntPtr hWnd, uint uCmd);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
static extern int GetClassName(IntPtr hWnd, StringBuilder lpClassName, int nMaxCount);
wbHandle = webBrowser.Handle;
StringBuilder className = new StringBuilder(100);
while (className.ToString() != "Internet Explorer_Server") // The class control for the browser
{
wbHandle = GetWindow(wbHandle, 5); // Get a wbHandle to the child window
GetClassName(wbHandle, className, className.Capacity);
}
//Show Click
System.Drawing.Graphics g;
g = Graphics.FromHwnd(wbHandle);
g.DrawEllipse(new Pen(new SolidBrush(Color.Red),15), yourX, yourY, 15, 15);
//g.DrawImageDrawString("X", this.Font, new SolidBrush(Color.Red), yourX, yourY)
g.Dispose();
|
|
|
|
|
Hello,
Beyond monitoring registry, file system, etc access with process monitor, and window messages with the likes of something like Winspector, is there a piece of software that can watch API calls of processes?
Thanks,
Matt
|
|
|
|
|
I was tempted to say .. 'look at Detours' qv http://research.microsoft.com/en-us/projects/detours/[^], but that doesnt help you in a C# environment AND I think you'd still have to know what API calls you were going to watch ahead of time ..
so Im sorry, this is a waste of a post - I hope someone else has useful info for you ..
'g'
|
|
|
|
|
That's very interesting, and brings up the point that the senior dev at my work said... detour/redirect the APIs.
I think that process monitor actually attaches a debugger to each process, this isn't enough?
What about analyzing the call stack (like process explorer), but in an on going logging manner?
Thanks,
Matt
[ud]
eyyy yo[^]
modified on Friday, March 20, 2009 8:21 PM
|
|
|
|
|
bbranded wrote: What about analyzing the call stack (like process explorer), but in an on going logging manner?
ok, I could see this being used for exploratory purposes/during development, but, 'on going' ... surely it would be very expensive cpu-wise ?
Interesting issue though .. does tickle something in the reccesses of my deep/gutter like brain .. something about someone with an instrumentation API for C# - but it wasnt making him/them any money so I think it got canned .. lets see...
well, it wasnt this http://tracetool.sourceforge.net/[^] I was thinking of, but it may give you ideas ...
'g'
|
|
|
|
|
I don't mean "on going," like on going, but more like how you'd use process monitor. Process explorer's call stack thing is very small, and simple.
I'm looking to passively observe, and am looking for a piece of software, although an API is cool too. I'm not particularly looking for a debugger, as I can't debug software I may need to monitor (I work at a hedge fund, and am a net and sys admin, but I do code in C#).
Are you speaking of fastice, or whatever that debugger is?
Thanks for the replies!
Matt
|
|
|
|
|
bbranded wrote: Are you speaking of fastice, or whatever that debugger is?
no, there was an instrumentation api/product out there - cant find it now
'g'
|
|
|
|
|
Sir,
can u state methods to extract data from hl7 message
|
|
|
|
|
|
Man, it sucks to be you. HL7 is a pile of crap embedded in a pile of crap. The technical documentation for it is several THOUSAND pages. Buy a parser - it's your only hope.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
In my application I use the Application Settings to store user preferences (such as preferred colors, size of the window, which parts or my program to hide or show etc)
But I'd also like to store an ArrayList in the settings.
Now I already have an ArrayList stored containing some simple integers (column widths), which works perfectly.
However, when I try to store an ArrayList containing a custom class (Group) which contains a string (name) and a boolean (isVisible) and I start up my application again (it saves the settings on exiting) the setting is empty, as if the arraylist never contained any groups.
At first I thought it was the custom class I made which would cause the problem, but I also store some values which are a custom class in the settings, so I doubt that's it.
I guess my problem is obvious here, why won't the Application Setting remember my ArrayList containing Groups?
For those interested in the Group class code:
public class Group
{
private string name;
private bool visible;
public Group(string name)
{
this.name = name;
}
#region Getters and Setters
public string Name
{
get { return name; }
set { name = value; }
}
public bool IsVisible
{
get { return visible; }
set { visible = value; }
}
#endregion
}
|
|
|
|
|
I've not tried it, but I guess decorating your class with the Serializable attribute whould allow it to be serialized to the settings
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
I am not really familiar with the whole Serializable attribute, but I read that adding [Serializable] above your class should do the trick.
So I did that, and now the ArrayList isn't empty, now it's null >_<
EDIT: I've been playing around a bit, and if I convert the contents of the group to 1 string, and store an arraylist containing those strings, it stores it fine.
So I either need to find some great tutorial on how that serialization thingy works, or I need to find another way to store this data (originally I stored in in a file next to the exe, but this, of course, is very error sensitive since it can easily be edited).
modified on Friday, March 20, 2009 6:28 PM
|
|
|
|
|
If you edit the Settings.Designer.cs file and add this attribute sbove your setting it should work.
[System.Configuration.SettingsSerializeAs(System.Configuration.SettingsSerializeAs.Binary)] This works for me.
using System;
using System.Collections;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
if (Properties.Settings.Default.GroupArray == null ||
Properties.Settings.Default.GroupArray.Count == 0)
{
Group group1 = new Group("Test1");
group1.IsVisible = true;
Group group2 = new Group("Test2");
group1.IsVisible = false;
ArrayList list = new ArrayList();
list.Add(group1);
list.Add(group2);
Properties.Settings.Default.GroupArray = list;
Properties.Settings.Default.Save();
}
else
{
foreach (object o in Properties.Settings.Default.GroupArray)
{
Group item = (Group)o;
Console.WriteLine(
String.Format(
"Name={0}, IsVisible={1}",
item.Name, item.IsVisible));
}
}
}
}
[Serializable]
public class Group
{
public Group(string name)
{
Name = name;
}
public string Name { get; set; }
public bool IsVisible { get; set; }
}
}
namespace WindowsFormsApplication1.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.Configuration.SettingsSerializeAs(System.Configuration.SettingsSerializeAs.Binary)]
public global::System.Collections.ArrayList GroupArray {
get {
return ((global::System.Collections.ArrayList)(this["GroupArray"]));
}
set {
this["GroupArray"] = value;
}
}
}
}
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Ahh, yes, the SettingsSerializeAs.Binary did it But won't that line get deleted everytime the Settings.Designer.cs is generated?
EDIT: Yep, everytime I add a new setting I have to add the line again. Of course having this working is awesome, and no, I won't be adding settings a lot, but this is something so easily overlooked, there has to be a better way to set that serializing to binary.
|
|
|
|
|
Yeah - I'll have a look into that.
By the way, ArrayList shouldn't really be used because of all the boxing/unboxing to and from object that's required. Unless you're stuck with 1.1 of the framework you should use a generic list i.e System.Collections.Generic.List<Group>
I don't know if you can serialize a generic list to the settings class. I've tried it by saving it as object and just casting the whole object to the list on load and that works OK.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Yea, I've been using ArrayLists since like forever, only just found out about the List (actually while looking for ways to get this serializing to work).
So if I ever get around to optimizing my code, I'll definitely use that, and of course in future code
Thanks for the help, and I hope to see a better way to set that serializing as binary, although you don't need to rush. This is just for a private little project I got here, experimenting new things while making my life easier (this is part of a tool that keeps track of all the tv shows I watch, displaying it in an organized way so I know which episodes or whichs shows I still have to watch, when they will air, etc).
|
|
|
|
|
The only way I can think of is to do your own serialization/deserialization in code to XML. If you do that you can simply save it in the user scoped application settings as a string.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
There's no way this should be such a pain! The code below demos how to serialize a generic list of a Serializable class to an XML string, and then recreates the list from the string.
I've kept the string in memory here, but obviously this can be read from / written to the settings. I haven't done any error checking etc so it's not complete, but should be enough get started!
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Windows.Forms;
using System.Xml.Serialization;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
Group group1 = new Group("Test1", true);
Group group2 = new Group("Test2", false);
GroupCollection groups = new GroupCollection();
groups.AddRange(new Group[] { group1, group2 });
string xmlString = groups.SerializeToXMLString();
groups.Clear();
Console.WriteLine(xmlString);
groups = GroupCollection.DeSerializeFromXMLString(xmlString);
foreach (Group group in groups)
{
Console.WriteLine(
String.Format(
"Name={0}, IsVisible={1}",
group.Name, group.IsVisible));
}
}
}
[Serializable]
public class Group
{
public Group()
{
Name = string.Empty;
IsVisible = false;
}
public Group(string name)
{
Name = name;
IsVisible = false;
}
public Group(string name, bool isVisible)
{
Name = name;
IsVisible = isVisible;
}
public string Name { get; set; }
public bool IsVisible { get; set; }
}
public class GroupCollection : List<Group>
{
public string SerializeToXMLString()
{
XmlSerializer xmlSerializer = new XmlSerializer(typeof(GroupCollection));
string xmlString = string.Empty;
using (MemoryStream memoryStream = new MemoryStream())
{
xmlSerializer.Serialize(memoryStream, this);
xmlString = FromByteArray(memoryStream.GetBuffer());
}
return xmlString;
}
public static GroupCollection DeSerializeFromXMLString(string xmlString)
{
GroupCollection result;
XmlSerializer xmlSerializer = new XmlSerializer(typeof(GroupCollection));
using (MemoryStream memoryStream = new MemoryStream(ToByteArray(xmlString)))
{
result = (GroupCollection)xmlSerializer.Deserialize(memoryStream);
}
return result;
}
private String FromByteArray(Byte[] characters)
{
UTF8Encoding encoding = new UTF8Encoding();
string xmlString = encoding.GetString(characters);
return (xmlString);
}
private static Byte[] ToByteArray(string xmlString)
{
UTF8Encoding encoding = new UTF8Encoding();
Byte[] byteArray = encoding.GetBytes(xmlString);
return byteArray;
}
}
}
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
modified on Friday, March 20, 2009 9:12 PM
|
|
|
|
|
Ok this has been bugging me all night. The trick is to use ApplicationSettingsBase[^].
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Windows.Forms;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
private GroupSettings groupSettings = new GroupSettings();
public Form1()
{
InitializeComponent();
List<Group> groups = groupSettings.Groups;
if (groups.Count == 0)
{
Group group1 = new Group("Test1", true);
Group group2 = new Group("Test2", false);
groups = new List<Group>();
groups.AddRange(new Group[] { group1, group2 });
groupSettings.Groups = groups;
groupSettings.Save();
}
else
{
foreach (Group group in groups)
{
Console.WriteLine(
String.Format(
"Name={0}, IsVisible={1}",
group.Name, group.IsVisible));
}
}
}
}
[Serializable]
public class Group
{
public Group()
{
Name = string.Empty;
IsVisible = false;
}
public Group(string name)
{
Name = name;
IsVisible = false;
}
public Group(string name, bool isVisible)
{
Name = name;
IsVisible = isVisible;
}
public string Name { get; set; }
public bool IsVisible { get; set; }
}
internal sealed class GroupSettings : ApplicationSettingsBase
{
[UserScopedSetting()]
[SettingsSerializeAs(System.Configuration.SettingsSerializeAs.Binary)]
[DefaultSettingValue("")]
public List<Group> Groups
{
get { return (List<Group> )this["Groups"]; }
set { this["Groups"] = value; }
}
}
}
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
I've leaned quite a bit from investigating this so I've put it together in an article here[^] if you're interested.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Yea, reading it now, thanks
I noticed an error in the article though. At the 'Your own types' paragraph you say there is no way to select your own classes as the type using the UI. This is wrong. When selecting the type you can also choose to browse, if it isn't in the menu there you can also just manually type it in and if you did correctly it will be used perfectly.
I.E. if you namespace is called 'MyFirstProgram' and you have a class called 'MyFirstClass' you could set the setting's type to MyFirstClass by selecting browse and typing 'MyFirstProgram.MyFirstClass' in the textbox and press OK
|
|
|
|
|
Interesting - I'm getting a 'Type xxx is not defined' error. Made sure there's no typos. I'll check it out more later.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|