|
C:\>cmd /?
Starts a new instance of the Windows XP command interpreter
CMD [/A | /U] [/Q] [/D] [/E:ON | /E:OFF] [/F:ON | /F:OFF] [/V:ON | /V:OFF]
[[/S] [/C | /K] string]
/C Carries out the command specified by string and then terminates
I think you need the /C parameter.
|
|
|
|
|
Hi,
Process.Start("shutdown", "-s -t 0"); is all you need assuming you have sufficient rights.
shutdown.exe is one of the Windows utilities, no cmd.exe required here.
[ADDED]
And with an amended 4-line approach like yours, the DOS window flashing can be avoided.
[/ADDED]
Luc Pattyn
Local announcement (Antwerp region): Lange Wapper? Neen!
modified on Sunday, September 27, 2009 2:37 PM
|
|
|
|
|
I don't have visual studio 2005 to run the chess program. But I have downloaded visual studio 2008 express because it is free. However I cannot succeed to make the program run on this plateform. Is there a simple way to make it running and what must I do?
Thanks,
Marcel Jacon
marcel.jacon@wanadoo.fr
|
|
|
|
|
Marcel51 wrote: However I cannot succeed to make the program run on this plateform. Is there a simple way to make it running and what must I do?
You could start by explaining what it is that does not run. Does the project compile cleanly, Do you have the full SDK libraries to support it, etc.?
|
|
|
|
|
I'm trying to add a button onto the toolbar so that everytime I click the button the dll file will be copied to a specific folder.
I used Assembly.GetExecutingAssembly().GetName().Name to find the assembly name of the current project, but instead it returns the assembly name of the add-in.
Also Directory.GetCurrentDirectory() only returns "C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE" instead of the path of current executing project.
Can anyone help me please?
|
|
|
|
|
I have no experience with VS add-ins, however (1) there must be several CodeProject articles on the subject, and (2) CP has a Visual Studio forum.
FYI: you can add "DOS commands" as pre- or post-build step to the build process; that is how I copy DLLs from one project to another. Disadvantage: you have to add the command once, advantage: it copies automatically.
Luc Pattyn
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Luc Pattyn wrote: pre- or post-build step
That's my suggestion also.
On the other hand, you can change the directory where the DLL/EXE is built -- I do that some times as well.
As an even more advance and unexpected solution, you could have the destination directory be a junction to the real directory -- I've done that.
|
|
|
|
|
Thank you guys for the quick replies.
However users can't add post-build event every time they create a project.That's what the button is for, it copies the assembly file of the current project to a folder(which should be specified by the user).
But Since the executing file is the add-in instead of the project, I dont' know how to get the file name and path.
|
|
|
|
|
|
I'm new to C# and new to programming in general, so please forgive me if I don't have my nomenclature down. I'd like to recreate one of my favorite utilities, Vitrite, a tiny open source program that allows you to right-click on any window, make it "always on top" and adjust its transparency. I've been reading up on hooking and writing background services, but I'm having some trouble finding a good primer explaining how to define properties for a global system object (is that the correct term?), or even if that's possible in C#.
To clarify, in case I'm not wording it correctly, I want to be able to define focus for any window that opens on my system. I'm teaching myself, so I'm happy to figure out the details on my own, but if anyone could get me pointed in the right direction, I'd appreciate it.
Thanks!
modified on Saturday, September 26, 2009 10:37 PM
|
|
|
|
|
If I understand the technique correctly, this is not possible to do in C# because it doesn't support the exports required in .DLL's to inject code.
|
|
|
|
|
hi
how i can fill collection from database and connect this collection to ComboBox ?
thank's in advance
|
|
|
|
|
Create the Data Source From DB. Set DataSource And DataMember Properties of Combobox. Thats All
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
Any way you like; have at it.
|
|
|
|
|
Hello,
How can i create an icon (like in MSN) when the user launch the application?
and to close it he have to close it from the TaskBar?
thank alot...
|
|
|
|
|
|
Thanks abhijit its nice
Shafik
|
|
|
|
|
By the task bar I assume you mean the system tray.
You need to handle the FormClosing event and add a NotifyIcon.
In the FormClosing, check if the form is Visible. If true, then hide the form, show the notify icon and set e.Cancel to true.
All that's left to do then is add a context menu to the notify icon so you can provide a way to exit and handle left/right/double click on the notify icon for unhiding the form and hiding the icon.
|
|
|
|
|
First select all product from database
private DataTable ShowProduct()
{
string mach = "select ID,Name from product";
cmd = new SqlCommand(mach,con);
adt = new SqlDataAdapter(cmd);
ds = new DataSet();
adt.Fill(ds);
return ds.Tables[0];
}
-----------------------------------------------------------------
Second build funtion create id auto
private int AutoID() //funtion create auto id
{
DataTable dt = new DataTable();
dt=ShowProduct(); //datatable store list id
int ma=-1;
int row = -1;
string mach1="";
int i = 0;
if (dt.Rows.Count > 0) //at least one id
{
int[] id = new int[dt.Rows.Count];
foreach (DataRow mach in dt.Rows) //assigned id in string array
{
ma++;
row++;
mach1 = dt.Rows[row][0].ToString();
id[ma] = Convert.ToInt32(mach1.Substring(2)); //get string index=2 to end converter int assigned id in string array
}
for (int j = 0; j < id.Length; j++) //create auto id
{
i++;
if (id[0] != 1) //first id !=1 set id =0
{
i = i - 1;
break;
}
if (id[j] > i) //id[j] != id[j-1]+1 set id=id[j-1]
{
i = id[j - 1];
break;
}
}
}
return i + 1; //return id need create
}
---------------------------------------------------------------
Using
private void bttInsert_Click(object sender, EventArgs e)
{
int id = AutoID(); ////Using
string idpro = "SP" + id.ToString().PadLeft(4, '0');
txtID.Text = idpro;
if (bttInsert.Text == "Insert")
{
txtName.Clear();
bttInsert.Text = "Save";
}
else
{
if (txtName.Text != "")
{
InsertSP(idpro, txtName.Text);
dgvShowSP.DataSource = ShowProduct();
bttInsert.Text = "Insert";
}
else
MessageBox.Show("Bạn chưa nhập tên sản phẩm");
}
}
Link download demo
CreateAutoID.rar
|
|
|
|
|
why dont you use GUID all the time.. Most useful for Primary Key....
|
|
|
|
|
I'm sorry, I speak English very bad. I idea every time user add product id auto create, information user fill out rest. I don't know GUID.
You can explain to me what the GUID?
|
|
|
|
|
You should be creating your own AutoIDs in the first place. They should be created by the database when you insert new records, not your code.
|
|
|
|
|
Every body should download demo and run. Every body will understand my idea.
|
|
|
|
|
Theres lots of info about adding buttons to title bar, like this: http://www.codeproject.com/KB/cs/mintraybtn.aspx
But ive seen a couple programs that can add a button like that to every windows window. Like an nvidia(IIRC) app which added a button next to the minimize on EVERY window. Now i need to be able to that, plus assign some code to the button.
Thanks guys.
Strive to be humble enough to take advice, and confident enough to do something about it.
|
|
|
|
|
That would suck; keep it off my system.
|
|
|
|