|
Yeah kinda. Things like changing the exe header...etc.
No way to do in c#?
K.D.
|
|
|
|
|
Maybe I'm showing my ignorance, but what special need is there for __asm when all you're doing is changing the contents of a file?
C# provides easy file access, just check the System.IO.FileStream and other classes within the System.IO namespace.
If you are trying to do more complicated things than merely reading and writing to the file (like trying to monkey with an already executing program), then you can try using the System.Runtime.Interop namespace to access most/all of the Windows APIs. If you still can't get there, then you can create a C++ dll to do the specific work you need, and call that from C#.
John
|
|
|
|
|
John is right. If all you are doing is modifying the file, there's no need for __asm , and C# supports binary file ops.
|
|
|
|
|
Can anyone figure out why the following code always throws an exception from the site, that the password is incorrect(401) even though when it is correct!
using System;
using System.Net;
class website
{
public static void Main(string[] args)
{
if (args.Length != 3)
{
Console.WriteLine("usage: p25 \"URL\" \"username\" \"password\"");
return;
}
WebRequest request;
WebResponse response;
try{request = WebRequest.Create(args[0]);}
catch
{
Console.WriteLine("The Url provided is not a valid Url");
return;
}
request.Credentials = new NetworkCredential(args[1], args[2]);
try{response = request.GetResponse();}
catch(WebException e)
{
Console.WriteLine("The following error occured while accessing the resources:\n"
+ e.Message);
return;
}
}
}
K.D.
|
|
|
|
|
|
Hi all.
I'm developing a class that inherits from System.ComponentModel.Component in much the same way as Timer etc.
What I need to know is "How do I get a reference to the parent Form?"
I need this so I can add a event handler for the forms Activated/Deactivated events.
I've looked though my MSDN and it happily defines the ISite interface properties but it doesn't show how the whole thing fits together.
Also, when I debug the component, this.Site and this.Comtainer are both null...Is there an attribute I need to add to the Component?
Thanks for any help you can give me on this guys (and Gals!)
Pete
Insert Sig. Here!
|
|
|
|
|
Um, perhaps in your form OnLoad :
MyControl.Site = (ISite)this;
"The greatest danger to humanity is humanity without an open mind." - Ian Mariano
http://www.ian-space.com/
|
|
|
|
|
Surely you havent got to wire this stuff up yourself? I may as well write my own Parent property if that were the case...
Anyone?
Pete
Pete
Insert Sig. Here!
|
|
|
|
|
Prepare a constructor with a IContainer param. This will be used to pass the parent. In System.Windows.Forms.Timer :
public Timer() : base() {
this.interval = 100;
}
public Timer(IContainer container) {
this = new Timer();
container.Add(this);
}
As you can see, this code doesn't store the reference to the parent anywhere, but that's up to you to do so.
Back to real work : D-28.
|
|
|
|
|
Nice... Thanks a lot. I'll have a got with this later this morning.
Cheers.
Pete
Insert Sig. Here!
|
|
|
|
|
Hi again.
Yeah, that works. The form code generator automatically adds the code to pass the components object to the constrctor and everything.
Unfortuantly, I have not idea of how to navigate from that Component object to the actual Form object, which is what I am interested in. Any ideas?
Surely the framework includes this? Or Maybe a Component based object is not what I want here?
Basically, what I'm after is the same as the Parent property on a Control. Except I'm not building a visible control, just a component that adds some event handlers to the forms events and does some processing based on them.
BTW, the Timer was just an example, I'm not actually using a timer...
Thanks
Guys.
Pete
Insert Sig. Here!
|
|
|
|
|
Pete Bassett wrote:
just a component that adds some event handlers to the forms events and does some processing based on them.
This is a different topic now.
To get it done, you need to declare a delegate, an event object, an eventarg object, and a handler. Adding this to a Form-derived class, along with appropriate [design-time] attributes will make the event handlers show in the Form designer.
Whenever the event handler is actually subscribed for, you have internal code executed where you can process the event using another component (non-visible if you like) of yours.
All you need is a good sample to start with. There are articles about new event creation on CP (C# programming section), MSDN, ...
Back to real work : D-27.
|
|
|
|
|
No, sorry for the confusion.
I understand all about event handlers etc etc etc. I just need a reference to the Form-derived object inside my Component. Thats all.
You told me to write the Constructor with one IContainer param and this works correctly, but I need a reference to the actual Form, not its internal Container.
Once I have the reference to the Form it will all work because all the rest of the code is written...
Have I explained the problem correctly now? Thanks again.
Pete
Insert Sig. Here!
|
|
|
|
|
I think I know what you mean...I had something similar where I wanted to get the HWND of the MainAppwindow wher I would "drop" the component, although there was no interaction with the window, it still needed to know this...
I wonder how this can be done? All my attempts were failures
"There are no stupid question's, just stupid people."
|
|
|
|
|
This one[^] might help, in conjunction with the IContainer.Add(this) mentioned above.
Back to real work : D-27.
|
|
|
|
|
Hi again.
I've had a look at the code but I don't think its the way.
I'm starting to think this isn't possible at all.
Well, thank you (all) again. I'll investigate some more and post back.
Pete
Pete
Insert Sig. Here!
|
|
|
|
|
Add form reference property in your component, and assign it when you initialize your component:
public class MyComponent : System.ComponentModel.Component
{
private Form m_oMyParent;
public Form Parent
{
get { return m_oMyParent; }
set { m_oMyParent = value; }
}
}
m_oMyComponent.Parent = this;
|
|
|
|
|
Hi.
Yes, I did this right at the start when I couldn't figure out how to do it automatically. This whole thread is just me trying to fine a more elegant way of doing this. i.e. without the client having to write any code.
Thanks again.
Pete
Pete
Insert Sig. Here!
|
|
|
|
|
How do i tell if the context menu has disappeared?
1001111111011101111100111100101011110011110100101110010011010010 Sonork | 100.21142 | TheEclypse
|
|
|
|
|
A context menu triggers commands. So once commands are triggered, the context menu has disappeared. This is a simple enough application logic!
Internally, the System.Windows.Forms.ContextMenu class is just a tiny wrapper on top of the WIN32 TrackPopupMenuEx API call. And as you'll see in the doc, one of the param passed in order to create and show a popup menu is the owning window. Which means this window gets notified of everything.
Back to real work : D-28.
|
|
|
|
|
Thankyou. You answered the question just how i like it, a nudge in the right direction, rather than a spoon fed answer
1001111111011101111100111100101011110011110100101110010011010010 Sonork | 100.21142 | TheEclypse
|
|
|
|
|
Hello!
I'm writing a personal account management program that relies on a sql server database. I have the following problem: I would like to ensure, that the sql server db can only be modified by my program (and the server administrator of course, i.e. me ). I considered creating a db user account with read/write access and accessing the server through this account. But even then I have to store the name and password somewhere in my application - which could easily be extracted, esp. with .net apps (Anakrino, ILDASM).
Is there any way to encrypt the password, without exposing the encryption mechanism and encryption keys (Anakrino, ILDASM)
I'm a bit lost
any help appreciated
Martin
"Situation normal - all fu***d up"
Illuminatus!
|
|
|
|
|
Martin Häsemeyer wrote:
Is there any way to encrypt the password, without exposing the encryption mechanism and encryption keys (Anakrino, ILDASM)
I know you are not working with ASP.NET , but have a look at FormsAuthentication.HashPasswordForStoringInConfigFile() method, it could be handy
"There are no stupid question's, just stupid people."
|
|
|
|
|
Hi!
Thanks for the answer but as I understand hash algorythms it is not possible to reconstruct the password from the hash. Therefore this can only be used to compare an entered password with the stored one (I use this technique for the passwords stored in my db with the System.Cryptography namespace). But what I need is a way to store the password so that I can send it to the sql serve and that the server can *understand* it, but my users can't. This means I must be able to decrypt the password without revealing the mechanism to the users...
Cheers
Martin
"Situation normal - all fu***d up"
Illuminatus!
|
|
|
|
|
Martin Häsemeyer wrote:
But what I need is a way to store the password so that I can send it to the sql serve and that the server can *understand* it, but my users can't. This means I must be able to decrypt the password without revealing the mechanism to the users...
Pretty clever users I understand your problem better now, but cant think of way you can "hide" password...
"There are no stupid question's, just stupid people."
|
|
|
|