|
Hello
is it possible to detect Installation Folder?what i want to create in my Application`s Folder only which normally is created in Program Files folder..
kindly guide me
-adnan
|
|
|
|
|
Is Application.ExecutablePath what you're looking for?
mav
|
|
|
|
|
Hi Guys,
I have a bit of code like this;
Code1:
Console.WriteLine(Int16.MaxValue);
O/P: 32768
Code 2:
string s="Int16.MaxValue";
Console.WriteLine(----------------);//using string s
O/P:
Should be 32768
Plz can u tell me how to Code1 o/p in Code 2:
In action script we use eval() keyword which produce required o/p
I am looking for ur reply.
Thanks,
Senthil Kumar Ramachandran.
|
|
|
|
|
Hello i have a problem i hoping someone might
be able to help with Using the registry in C# ?
I have found all kinds of sample code on the net
and have gotten it to work fine, but..
I am trying to make a small program for myself
to help add some of my registry changes
that i always do when i re-install windows..
So far i have been able to get/retrieve all kinds
of keys and it all works fine basicly, until
i come to one registry change i am trying,
and that is i want My Windows XP to "Auto Logon"
with out having to use a .reg file (what i used to do)
The problem is C# creates the wrong type of key
when i create a null entry.. here is what i mean..
private void checkBox1_CheckedChanged(object sender, System.EventArgs e)
{
RegistryKey OurKey = Registry.LocalMachine;
OurKey = OurKey.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", true );
OurKey.SetValue("AutoAdminLogon","1");
OurKey.SetValue("DefaultPassword","");
OurKey.Close();
}
You see when this code is executed it creates
thge DEFAULT "key type" for Reg_Sz which actualy
is not the same as having a normal blank key.
Look at the registry section mentioned in the code
for either, LegalNoticeText or System,
right click the key and select "modify binary data"
it will look diff than the key at the top that says (Default).
So to make this clear i want to create a blank key (string) Reg_Sz named = DefaultPassword
BUT not a Default Reg_Sz key..
So i had done all this waaaay easier before with C++
and now i have to say i am a little disapointed with
how crappy the C# registry functions are !
So can anyone out there help me out with this ?
also this is the page on MSDN that mentions the C# code.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfmicrosoftwin32registrykeyclasstopic.asp[^]
Edit:
well i decided to just create a .reg file
and execute that from my program with this line,
System.Diagnostics.Process.Start(@"XP-AutoAdminLogon.reg");
that works ok.. but its too bad i cant find a way
to create a proper blank string value in C#
(with out it beeing a normal default type)
|
|
|
|
|
xpmule wrote:
and now i have to say i am a little disapointed with
how crappy the C# registry functions are !
Had you read the note under the members topic for SetValue, you would have seen that the type of key created is deterimined from the way you pass in the value data. You passed in an explicit empty string, so you get an sz_string valued key containing the empty string you asked for.
Try passing in a zero length byte array or a null object... And RTM before you complain.
Anger is the most impotent of passions. It effects nothing it goes about, and hurts the one who is possessed by it more than the one against whom it is directed.
Carl Sandburg
|
|
|
|
|
Well first off i was trying to keep my post short.
I have tried many thing everyday for almost a week
and all results were a failure..
Windows will only recognise one type of key
for autoadmin logon to work and when passing
a "null" value, the default key type is created
which if ya check what i was saying earlier
that it has a diff binary value and in turn
windows will reject the key and ask for the password.
So the easy answer would be for me to set
a password, not leave it blank.
but i don't want to do that though.
oh and the passing an array idea
produced the wrong type of key.. REG_MULTI_SZ
and like i was saying that won't work
(for windows auto logon to function)
and here is the code i used..
private void checkBox1_CheckedChanged(object sender, System.EventArgs e)
{
RegistryKey OurKey = Registry.LocalMachine;
OurKey = OurKey.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", true );
string[] strMyArray;
strMyArray = new string[0];
OurKey.SetValue("AutoAdminLogon","1");
OurKey.SetValue("DefaultPassword",strMyArray);
}
So im thinking I found a limitation in the C# Reg Class
that wasn't a problem in the least when
i used c++ before to make the same program.
And if anyone can help me get the desired result ?
That would be great and I thank you kindly in advance !
Oh and to make this perfectly clear !
I didn't make this post to "complain" about C#
Rather to ask for some help..
I am really new to C# and am enjoying learning
all this and have found a way around my problem for now.
And i didn't mean to poop on C#
it has amazed me a lot already in how
easy it is to learn and use.
|
|
|
|
|
hi all ,
how can i detect that my application is running from CD-Rom Drive and not from HD
thank you
|
|
|
|
|
use
Environment.CurrentDirectory
to get the current directory of your application and check it yourself
|
|
|
|
|
Better than the current directory (suggested in the other post) use Application.StartupPath . It will always contain the folder where the EXE is located, even if the application changes the current directory (possible and more or less common.)
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
after drawing an ellipse on the form i want that if anyone clicks on the ellipse, it's properties should be displayed in a message box.
anyone with any one pls do mail me.
thanx a lot
Er.Tushar@gmail.com
|
|
|
|
|
hi there,
HW I guess (If not, my apologize)
just few hints look at Region and GraphicsPath classes.
I think it should be easy...
MSDN[^]
best regards,
David 'DNH' Nohejl
Never forget: "Stay kul and happy" (I.A.)
|
|
|
|
|
Hi, i want to send mouse click like "SendKeys", can I do it with shell or what should I use for it?
|
|
|
|
|
Can anyone point me to any opensource C# finite automations software or something that can be related to finite automations theory? Any link on this subject is greatly appriciated.
Thanks in advance!
|
|
|
|
|
|
Hate to disapoint you but I already saw and read that...
Thanks anyway
|
|
|
|
|
Hi,
I have created a user login screen for an application. What i want to achieve is the focus of the login button so that when a user hits the enter key the button is triggered that will process the user name and password.
Thanks for any help.
Regards,
Stephen McAllister
|
|
|
|
|
form1.AcceptButton = your_button.
Process the user name and password from the your_button click event.
<italic>Work hard and a bit of luck is the key to success. You don`t need to be genius, to be rich.
|
|
|
|
|
Now i am doing dragdrop with my usercontrols, such as button. I got these
two; CF_XMLCODE dataformat and
Microsoft.VisualStudio.Designer.Serlization.DesignerSerializationObject
datatype from the e argument of the dragdrop event. However I can't find any
reference about these two. What are they ? How can i use these to retrieve
all data and recreate my draging usercontrol ?
Thank you
|
|
|
|
|
hii
i am trying to make an flowchart kind of editor. i can draw an object. now i want to implement a click event in that object so that whenever it is selected, i can do something. the code for the object class is :
public class MyObject
{
private int m_X;
private int m_Y;
private int m_Width;
private int m_Height;
private string m_Text;
public MyObject()
{
m_X=m_Y=m_Width=m_Height=0;
m_Text=null;
}
public MyObject(int s)
{
m_X=m_Y=m_Width=m_Height=0;
m_Text=s.ToString();
}
public MyObject(int x,int y, int width,int height)
{
m_X=x;
m_Y=y;
m_Width= width;
m_Height= height;
m_Text="M";
}
public MyObject(int x,int y, int width,int height,string s)
{
m_X=x;
m_Y=y;
m_Width= width;
m_Height= height;
m_Text=s;
}
public MyObject (string s)
{
string[] temp = new string [5];
char[] c = new Char [2];
c[0] = ';';
temp = s.Split(c,6);
X= Int32.Parse (temp[0]);
Y=Int32.Parse (temp[1]);
Width = Int32.Parse (temp[2]);
Height = Int32.Parse (temp[3]);
Text = temp[4];
}
public int X
{
get { return m_X;}
set { m_X= value;}
}
public int Y
{
get { return m_Y;}
set { m_Y= value;}
}
public int Width
{
get { return m_Width;}
set { m_Width= value;}
}
public int Height
{
get { return m_Height;}
set { m_Height= value;}
}
public string Text
{
get { return m_Text;}
set { m_Text= value;}
}
public void Draw (Graphics g)
{
//Graphics g= f.CreateGraphics();
g.DrawEllipse(System.Drawing.Pens.Chocolate ,X,Y,Width,Height);
g.DrawString(Text,new Font("Arial",12),System.Drawing.Brushes.BlueViolet,X,Y);
}
public void WriteToFile(StreamWriter w)
{
w.WriteLine(X +";"+Y + ";" + Width + ";" + Height + ";" + Text);
}
public void Delete()
{
// this.Finalize ();
}
}
}
Please someone help me that if how do i do this : if i click this object then a messagebox if poped up !
thanx in advance
|
|
|
|
|
Create your object as a new user control in your project (Add new item, UI, User control).
The simply add the object to you main from (from the toolbox/My User Controls) and progam the "click" event for the object.
|
|
|
|
|
this is not a user control.
i even tried inheriting my class from usercontrol but then also the click event is not working.
The click event only works on the form. its not working on the Myobjects.. i don't know y.
I feel as if i am totally lost..
please someone help me !!!
|
|
|
|
|
piscian1982 wrote:
The click event only works on the form. its not working on the Myobjects
Because your object is not a control that can trap user events. It draws itself on the form, but you would need the form to trap the click event and forward to your object.
Or your object could install an event handler for the Click event of the form, and check in the delegate if the location of the click is inside your object, and if so, react accordingly. If the point is outside your object, just let the form process its event.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
I'm not sure but, in _KeyPress event of a textbox, if you add the code "e.Handled = true;", it works fine. The event is cancelled. But in _KeyDown event it doesn't work.
<br />
private void t2_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)<br />
{<br />
e.Handled = true;<br />
}<br />
Is this a bug? or am I missing something?
Radgar
"Imagination is more important than knowledge." - Albert Einstein
|
|
|
|
|
Yes, it's a bug, it has been fixed in .NET 2.0
Regards
Senthil
|
|
|
|
|
Thanks Senthil.. Same goes for ComboBox control too..
Radgar
"Imagination is more important than knowledge." - Albert Einstein
|
|
|
|