|
i have a fairly broad question here. What im intrested in doing is adding a extension to the standard windows context menu (i.e when you click on the bar desktop). i want to add exstentions too my encryption/decryption program. how can i do this ? if its easy... please reply with a good Code exsample.. if its a apsolute pain could you point me in the right direction to teach myself? (or both). thanks alot
Jesse M.
|
|
|
|
|
You will have to learn COM first to achieve this.
To do this from .net you need to know about COM interop from .net
Have you a look at the following article
http://www.codeproject.com/shell/shellextguide1.asp[^]
There is a sample that comes along with framework sdk, search for Shellcmd in the samples folder, this tells you how to add a menu item to explorer's context menu.
Cheers
Kannan
|
|
|
|
|
I am designing and coding a C# application. It is intended to be a visual display of the navigations between the various files we have. Example:
A page file defines a page to display.
It contains a collection of events to be managed.
The eventmanager file tells me who handles each event.
The event file tells me when the event is handled, the next page to display and the rules to execute to determine if it's valid.
So each event represents a branch in my nav model.
I thought of doing this display like Frontpage navigation or Visio. I thought of doing a custom button with a simple square as its' graphics. Each page name would populate the button.text property and I would programmatically draw a line between each control. I was also going to do this as a fat client app.
What I want (the hard part) is since these navigations can be very shallow or they can be very wide that as I populate the form with these controls that it pops up the scroll bars as needed so that the client can scroll to the parts of the navigation model that they want to view. I should mention I was hoping to do this without having to move the entire model down as I hit the 'upper edge' of the form with a wide navigation, but doing a global move is fine if I have to.
For our first version we are only displaying the navigation model given a starting page. So there you have it. Has anyone built something like this? Am I going to be feeling lots of pain for the next month coding this? Any time bombs waiting to derail me as I execute it? Any advanced assistance would be greatly appreciated.
_____________________________________________
The world is a dangerous place. Not because of those that do evil, but because of those who look on and do nothing.
|
|
|
|
|
Before I ask my question, let me give some quick background. My current employer has recently decided that downloading certain files (.zip, .exe, etc) slows down the internet performance for the rest of the internet users. So, as a result, they have modified the proxy server to no longer allow such downloads during peak internet hours (8:00 - 3:00 PST). Because of this, I am no longer allowed to download files I need for work without writing a 3 page justification and getting it signed off by 3 levels of managers and then waiting for the right department to give me access and hope the access they give me has a long enough window to get what I need.
That's the background, now here's my question. Is it possible, and if so any ideas on how to go about it, to create a web service which I could give a URL (presumably to a .zip or .exe file) and it would get the file and then stream it to my client? I am still able to consume web services through our proxy, so this would solve my dilemma.
Thanks in advance for any ideas, suggestions, help, pointers, etc.
Larry
|
|
|
|
|
Its definately possible (I wrote something similar in Perl with SOAP::Lite). In fact, it won't even be that hard.
In C#, create a Web service, and then just use a WebRequest/WebResponse object to get the file (I hope you don't need to use HTTP POST to get your files!) and then serialize it and return it.
-Adrian
|
|
|
|
|
You can also try using some proxy tunelling software like Multiproxy or some https free anonymity proxy service.
I see dumb people
|
|
|
|
|
You could give a string as parameter to the path of the file when calling a webservice method (eg. DownloadFile("C:\\blah.exe") ).. That method just reads the file you specified into a byte[] and returns that. Then it would be the best to write a client which you run, and which allows you to specify the path and write the byte[] to a file so you actually saved the file.
Ofcourse, if you do it exactly like this, you can download like everything, but I think thats another question .
|
|
|
|
|
How can take the text from the textBox and save it as a Binary data in the registry?
Many Thanks,
Jassim Rahma
|
|
|
|
|
Hey Jassim,
The Text is stored within textbox.Text property. Look in the C# articles for "QuickRegistry" and use that for storage.
-Adrian
|
|
|
|
|
but this will just create a plain text and not binary one? how to convert it to binary?
Jassim
|
|
|
|
|
In order to store something as a REG_BINARY type using .Net, it needs to be passed as a byte array.
Getting a byte array from a string is as simple as:
byte[] bytArray = System.Text.Encoding.Unicode.GetBytes(textBox.Text);
Then pass bytArray into a RegistryKey's SetValue() function:
MyRegKey.SetValue("MyBinaryEntry", bytArray);
The CLR will automatically detect that the type is a byte array, and set the type accordingly. Retrieving that value will return a byte array also, not a string.
Cheers
|
|
|
|
|
But this will not encode it and it will be easy for anyone to read it? how can have it encoded in the same code?
|
|
|
|
|
If you feel it's too easy for someone to read the binary data, there are any number of encryption algorithms out there. You can apply one before placing the data into the registry.
|
|
|
|
|
But will it be easy for someelse to decrypt it? I need to save a system pssword, what do you recommend?
Jassim
|
|
|
|
|
How can I place the minimized MDI child windows on the MDI container statusBar just like the windows task bar?
|
|
|
|
|
I have now completed my first real C# program - its a nice system tray thing with a notifier that goes and notifies me when I have new web mail by doing HTTP Post/Gets (these response with an XML reply which I then parse). It also uses the TaskbarNotifier class and the QuickRegistry class that I found in the CodeProject articles (many thanks to the respective authors for these).
My only problem is that the release version of the build consumes 14MB of RAM. I compare this with msnim (which Im sure is written with .NET) and other "long running" processes of the same caliber, and I can only come to the conclusion that I need to reduce the running footprint of my program.
Next Q: What can I do to reduce the running footprint?
I have:
* Changed the build type to "Release"
* Removed TRACE from the build parameters (under Conditional Compilation Constants)
Is there anything else in general I can do, or do I start attempting to rework code at this point to make it lighter weight? (e.g. constant sized strings rather than dynamic strings)
-Adrian
|
|
|
|
|
Hmmm.. The size of your application looks ok for a .NET Windows Forms application. Unfortunately, this is the price you pay for all those neat features.
You can try calling GC.Collect() at strategic points to reduce the memory footprint.
Changing your strings won't help. You can try this[^] and try to locate some points for improvement, but don't expect to go lower than 9~10Mb.
I see dumb people
|
|
|
|
|
How are you checking memory usage? I tried Process.WorkingSet and it seemed to keep eating memory. I'm after a more "lite weight" way to check memory usage in my apps
|
|
|
|
|
If the WorkingSet directly refers to what you have through the task manager, then don't waste your time with it. You've got to check out the "virtual memory" indicator, which is much more trustable.
|
|
|
|
|
Unfortunately, task manager does not report true memory usage, it reports what it "thinks" an app needs - try it out for yourself
load up word or something similar
open task manager and find the instance of the program you have just started
While task manager is open, minimize the app
watch the memory usage drop.
I did this with Word and the memory usage in task manager dropped from 14 meg to 500k - somehow I don't think that it's reporting correct memory here.
Process.WorkingSet is supposed to report the memory usage used by the enitre app (and any component dll's?) but the last time I used it, my memory usage blew out to 110 meg after 6 - 7 hours, and I think this is what caused the high memory usage - this is why I'm after a more "liteweight" of checking memory usage.
|
|
|
|
|
Omega501 wrote:
Unfortunately, task manager does not report true memory usage, it reports what it "thinks" an app needs
That's exactly what I have been telling you. Get rid of the WorkingSet, that's not trustable.
Omega501 wrote:
load up word or something similar
open task manager and find the instance of the program you have just started
While task manager is open, minimize the app
watch the memory usage drop.
when you say "memory usage" you are talking about the WorkingSet, right ?
|
|
|
|
|
.S.Rod. wrote:
when you say "memory usage" you are talking about the WorkingSet, right ?
Nope, as far as I know, WorkingSet reports the correct memory usage of the app. Task manager lies a lot, so it's not something you can trust.
|
|
|
|
|
I don't beleive that Instant Messenger is written with the .NET Framework, so it's probably not a good comparison. For a managed application, 14MB seems reasonable to me. However, if you want to trim your working set, you might try calling this, which might free up 10MB of code that gets used as part of initialization, but might not be needed to run...
Warning: this might not work on Windows 9x. If you've got that in your target configurations, you might want to test for it in Empty below...
using System.Runtime.InteropServices;
namespace PutYourNamespaceHere {
internal class WorkingSet {
internal static void Empty() {
SetProcessWorkingSetSize( -1, -1, -1 );
}
[ DllImport( "Kernel32",
CharSet=System.Runtime.InteropServices.CharSet.Auto,
SetLastError=true)]
private static extern bool SetProcessWorkingSetSize(
int handle, int min, int max);
}
}
Burt Harris
|
|
|
|
|
First, thanks for the cool tip, will try it out in one of my apps.
Is there a sane way of knowing the amount of memory consumed by a .net application, for ex. if I have an application A and application B running, the task manager shows a big chunk of memory used by both these apps.
I'm almost sure the task manager is wrong.
Is it true that the runtime is being shared by these two apps, how do I find out the individual memory consumptions of these two applications.
thanks
Kannan
|
|
|
|
|
I'm pretty sure the runtime will be shared, but it's a little outside my area. Some of the details depend on what OS you are running (9x vs NT based). For this sort of thing, the www.sysinternals.com website has some pretty cool tools. I also highly reccomend their book, as it might provide answers to those sorts of questions.
Burt Harris
|
|
|
|