|
Thanks guys for the advices. It have help me a lot.
|
|
|
|
|
Following is a sample of a C# class I created for one of my software projects.
I use it to register my application in the shortcut menu (right-click menu) of
all the files and folders of the HDD. I chose a simple registry approach to
this problem beacause I find it much easier than buiding and registering a COM
object (and I must say I'n not really into COM programming right now, so it
will be kinda hard for me to learn now, having to finish my project a.s.a.p.).
Basicly, the Associate function takes three parameters, the name of the
extension, the desired text to display and the path to the .exe file. (EG. If I
need to register DoIt that is located at C:\DoIt.exe and display the text DoIt
in the menu i use Associate("DoIt", "&DoIt", "C:\DoIt.exe") ). It works by
going to HKEY_CLASSES_ROOT in the registry and opening/creating the
AllFileSystemObjects subkey, whitch handles all the files and folders. It then
creates three new subkeys in this order shell \ extensionName \ command and
registers the .exe so that it is displayed in the right-click menu.
Everything works well, but I still have a problem. I need the path of the file
or folder on whitch I right-click to be sent as a parameter to my main
application (same as using command-line parameters) and I do this by adding %1
after my application's path in the registry (line 26 of the class). However,
this works only if I have a single file or folder selected and I was wondering
if it is possible to use this method to send multiple paths as parameters to my
application (by selecting multiple files or folders or both).
I would really appreciate your help beacause I'm... well, stuck. 10x a lot.
P.S. Please don't hate me for the long description or for the almost childish
manner that I used to express it, but I wanted my problem thoroughly
understood. No offence meant.
using System;
using Microsoft.Win32;
namespace ShellExtension
{
public class ShellExtension
{
public ShellExtension() { }
public void Associate(string extensionName, string extensionText, string filePath)
{
RegistryKey ClassesRoot = Registry.ClassesRoot;
RegistryKey AllFileSystemObjects = ClassesRoot.OpenSubKey("AllFileSystemObjects", true);
if (AllFileSystemObjects != null)
{
RegistryKey shell = AllFileSystemObjects.OpenSubKey("shell", true);
if (shell != null)
{
shell.SetValue("", extensionName);
shell.CreateSubKey(extensionName);
RegistryKey shell_1 = shell.OpenSubKey(extensionName, true);
shell_1.SetValue("", extensionText);
shell_1.CreateSubKey("command");
RegistryKey shell_2 = shell_1.OpenSubKey("command", true);
shell_2.SetValue("", "\"" + filePath + "\" \"%1\"");
return;
}
else
{
AllFileSystemObjects.CreateSubKey("shell");
this.Associate(extensionName, extensionText, filePath);
return;
}
}
else
{
ClassesRoot.CreateSubKey("AllFileSystemObjects");
this.Associate(extensionName, extensionText, filePath);
return;
}
}
public void unAssociate(string extensionName)
{
RegistryKey ClassesRoot = Registry.ClassesRoot;
RegistryKey AllFileSystemObjects = ClassesRoot.OpenSubKey("AllFileSystemObjects", true);
RegistryKey shell = AllFileSystemObjects.OpenSubKey("shell", true);
if (shell.OpenSubKey(extensionName) != null)
{
shell.DeleteSubKeyTree(extensionName);
}
return;
}
}
}
Born from the dark, in the black cloak of night.
|
|
|
|
|
when i write the date in win.txt
it was like this
Lsbox_Date.Items.Add(DTP_Today.Value.ToShortDateString());
so if the regional setting was set to MM/dd/yyyy it will write the date the same as regional setting
so i change it to this which always gonna be dd/mm/yyyy
Lsbox_Date.Items.Add(DTP_Today.Value.Day.ToString()+
"/"+DTP_Today.Value.Month.ToString()+"/"+DTP_Today.Value.Year.ToString());
when i read the win.txt
this code is reading the date from win.txt
StreamReader Read_key = File.OpenText(@windir+"\\Win.txt");
string key_Trim;
string key;
key_Trim = Read_key.ReadLine();
key = key_Trim.TrimEnd();
Read_key.Close();
Convert the key to datetime
DTP_Key.Value = Convert.ToDateTime(key.ToString());
so if the regional setting is set to dd/mm/yyyy i have no Problem coz the format is the same
but if the regional setting is set to mm/dd/yyyy then i get an error converting the key string.
i need help pls ASAP
|
|
|
|
|
Use a explicit CultureInfo for writing and reading the date to be independent from setting of the PC:
System.Globalization.CultureInfo culture = new System.Globalization.CultureInfo("en-US");
DTP_Today.Value.ToString("d", culture);
Convert.ToDateTime(key.ToString(), culture);
www.troschuetz.de
|
|
|
|
|
is it possible to have two assemblies having same attributes.
please let me know if there are any good documents for this.
|
|
|
|
|
I'm not sure that I understand what you're trying to accomplish here, but... As far as I know, the only requirement for an assembly to live in the GAC is that it has a unique strong name. Google will yield plenty of results, if you search, but there are a couple of links to get you started:- An entry[^] on the GAC from Prabhu Ram Prasath's blog
- Jan Seda's article[^] here on CodeProject.
Hope that helps.
--Jesse
|
|
|
|
|
Hey too good articles.............
solved too many doubts I had.............
Prabhu Ram Prasath's dothis guy have some more aricles on anything like this......
And as I am sending u the reply I have one more question......
How does reflection helps GAC and Also WebServices, Bcoz I have seen so many exmples where people use refletions to call web service methods. I dont what might be the exact reason.
Regards,
|
|
|
|
|
IamADotNetGuy wrote:
Prabhu Ram Prasath's dothis guy have some more aricles on anything like this
I honestly don't know. I found that article when I ran a quick google while answering your post.
IamADotNetGuy wrote:
How does reflection helps GAC and Also WebServices
There have been tons of things written on reflection in .NET. If you're truly interested, I'd encourage you to search the articles here on CodeProject and google the topic. They'll do a better job of covering the topic then I can in a reply. In my experience the most common use for reflection is to enable late binding of an object. Again, if you're not familiar with late binding and would like more information, I'd encourage you to google it. Here[^] is an MSDN article to get you started.
Hope that helps.
--Jesse
|
|
|
|
|
As we know we can pass the parameters by ref and also by val.
Sometimes we will pass object as reference type even though they are already reference type.
Please feel free to say dont be stupid
|
|
|
|
|
You need to pass an object by ref, if the method you're passing it to will replace it with another object.
This example is useless, but it shows the effect:
<br />
private void DummyReplaceTwoStrings(String s1, String s2){<br />
s1 = "first text";<br />
s2 = "second text";<br />
}<br />
<br />
private void ReplaceTwoStrings(ref String s1, ref String s2){<br />
s1 = "first text";<br />
s2 = "second text";<br />
}<br />
<br />
private void CallerMethod(){<br />
String s1 = "hello";<br />
String s2 = "world";<br />
<br />
DummyReplaceTwoStrings(s1, s2);<br />
Console.WriteLine(s1);<br />
Console.WriteLine(s2);<br />
<br />
ReplaceTwoStrings(ref s1, ref s2);<br />
Console.WriteLine(s1);<br />
Console.WriteLine(s2);<br />
}<br />
_________________________________
Vote '1' if you're too lazy for a discussion
|
|
|
|
|
|
Better now?
You've won a personal extra-ref: r e f
_________________________________
Vote '1' if you're too lazy for a discussion
|
|
|
|
|
Hi,
I am trying to open a word document.It creates a application instance (winword.exe) but fails to open ,instead gets hanged.
when I try to kill the process it says access denied.
please help
Sukanya
|
|
|
|
|
It's impossible to tell you want your doing wrong when you haven't posted a code snippet showing how you're launching Word.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Some (or many?) of the useful Windows APIs have not made it yet to the .NET FCL. For example I was searching for the NetServerEnum() API equivalent functionality in FCl but could not find it. Had to do interop and call the API…
In general what is the policy on the relation and availability of Win32 APIs and .NET FCL? Will all the APIs be available with .NET FCL in future? What were the criteria to include some of the APIs in current version of the FCL and exclude some?
Salil Khedkar [^]
|
|
|
|
|
Hi folks!
I am trying to convert EBCDIC file to ASCII file. the issues are
1) Can all EBCDIC file be converted to ASCII without loss of information.(There is one character cent sign which is not in ASCII, how to handle that?)
2)What about non printable characters in EBCDIC, do they all converted to ASCII format?
Suggest some way.
Thanks n Regards
Ranjan
|
|
|
|
|
I have a picture box which is 48x48 in size and I want to set the image at runtime using a System.Drawing.Icon object which I have previously loaded.
I wish to know how I can display the icon in the picture box so the quality and resolution is the same as if I selected an icon file in design time and assigned this to the PictureBox.
At present I am converting the icon object to a bitmap (iconObject.ToBitmap()) and using this to populate the PictureBox. However this results is a grainy/poor quality image appearing in the picture box.
If I set the image property of the PictureBox at design time by selecting an icon file (*.ico) the image displayed is very crisp and clean and is at the highest resolution the icon supports.
I guess that I need to do some sort of image conversion from the icon object to some sort of high resolution image object. The .ToBitmap() method in the Icon object is obviously not sufficient.
Can anyone help please?
Can you tell me how I should be assigning icons to the image property so they are displayed at the high resolution I get when doing it in design time?
Ben
|
|
|
|
|
I use windows media encoder SDK to insert Mark In and Mark Out. But it will cut the selected part to be a new file.
I want to just insert markers without cutting. Can it be done?
Please help
|
|
|
|
|
In my application, the majority of data is taken not from a database, but is generated by the application itself.
Now before report generation I have to spread these data across tables for the sake of a single report.
It's too inconvenient.
Is there a way to do it directly, or, ideally, visually?
|
|
|
|
|
I think u can use flat files concept.
U can create a text file and copy all that is needed to generate your report
Sukanya
|
|
|
|
|
Hi there,
I try to find on the internet on how to achieve this, but still can't find any good resources till i downloaded Nant.
But there are too many codes inside Nant, and i have no idea which part of Nant code that can achieve this below.
<?xml version="1.0"?>
<project name="Property Test" default="test" basedir=".">
<property name="project.name" value="PropertyTest"/>
<property name="project.version" value="1.0.0"/>
<target name="test">
<echo message="Building ${project.name}-${project.version}"/>
</target>
</project>
--> I want to get the value of project.name. So i can use the ${project.name} a few times in my xml script.
Any idea on how to achieve this?
Thanks.
Regards,
Chua Wen Ching
Visit us at http://www.necoders.com
|
|
|
|
|
You should check out the NAnt documentation here[^] specifically the Properties[^] section of the documentation. This should get you started.
|
|
|
|
|
Hi Ian,
You get me wrong! I just want to know how NAnt can be able to achieve that.
I want to achieve this in my own custom xml script.
<Command id="1">
<DataIn>1234</DataIn>
<DataOut id="output">5555</DataOut>
</Command>
<Command id="2">
<DataIn>${output}</DataIn>
</Command>
I want to achieve the same way like what NAnt can do. But i do not
how know NAnt achieve that. I saw the source code, and there are so
many class files.
I am not looking for how to use NAnt with the property, just how to code the same way in my software.
Any tips please?
Thanks.
Regards,
Chua Wen Ching
Visit us at http://www.necoders.com
|
|
|
|
|
Hi
I am new to CSharp and have a question that might be quite straightforward to you gurus.
I have a system.collection.queue object. One thread X enque objects into this queue and another thread Y dequeues object and process them. I want to add a listener in thread Y so that anytime an object is enqueued into this queue, this method could be invoked. Any idea and code example in CSharp will be highly appreciated.
TIA
|
|
|
|
|
hello ,
I have a problem in retreiving the innerXml values from an XML File . The File is pasted below and the method I use is also listed below .
I want to list out the values Sylesh1,Sylesh2,sylesh3........ sylesh9 to an
arrayList .
The Method I use is... below but somehow I cannot retirve the values under the Path. Please point out my errors ?
XmlDocument _Document = new XmlDocument ();
_Document.Load (FileName);
XmlElement _Root = _Document.DocumentElement ;
XmlNodeList _NodeList = _Document.GetElementsByTagName
("configuration/userNames/sylesh/add/listGridCustomizations/myListGrid");
if (_NodeList.Count > 0)
{
foreach (XmlNode _Node in _NodeList)
{
List.Add(_Node.Attributes.GetNamedItem ("value").InnerText);
}
}
Any help ? suggestions ?
or if I'm wrong please point out ?
thanks Sylesh
<configuration>
<configsections>
<sectiongroup name="userNames">
<sectiongroup name="sylesh">
<sectiongroup name="listGridCustomizations">
<usernames>
<sylesh>
<add key="IsCustomized" value="false">
<listgridcustomizations><mylistgrid>
<add key="Column0" value="Sylesh0">
<add key="Column1" value="Sylesh1">
<add key="Column2" value="Sylesh2">
<add key="Column3" value="Sylesh3">
<add key="Column4" value="Sylesh4">
<add key="Column5" value="Sylesh5">
<add key="Column6" value="Sylesh6">
<add key="Column7" value="Sylesh7">
<add key="Column8" value="Sylesh8">
<add key="Column9" value="Sylesh9">
<listgridcustomizations><wrwerwer>
<add key="Column0" value="Sylesh0">
<add key="Column1" value="Sylesh1">
<add key="Column2" value="Sylesh2">
<add key="Column3" value="Sylesh3">
<add key="Column4" value="Sylesh4">
<add key="Column5" value="Sylesh5">
<add key="Column6" value="Sylesh6">
<add key="Column7" value="Sylesh7">
<add key="Column8" value="Sylesh8">
<add key="Column9" value="Sylesh9">
Thanks
Sylesh
sylesh
|
|
|
|