|
|
I am hoping to write a c# program to log which applications have been started and which ones become active/in focus. I assume I will need some api of somesort or is there something in the .net framework I can use.
Please help
thanks in advance
cjp
|
|
|
|
|
Well, you could periodically poll the System.Diagnostics.Process.GetCurrentProcess() list to see which apps are started. As far determining the active window, there is nothing in the .NET framework to return that information. You'll need to P/Invoke into a Win32 API to obtain this information.
|
|
|
|
|
Hi
a m new in c#
there are some methods of vc++.i want to know what we call in c#
memcpy()
memset()
memcmp();
just i want to copy,compare a block of byte from one buffer to another
and set buffer to null;
and How we can create link list pointer
Parshant
-- modified at 10:30 Thursday 14th September, 2006
|
|
|
|
|
You basically cannot do memory management in C#, so those methods don't have any equivalent in .NET.
What are you trying to achieve?
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
|
|
|
|
|
You can copy a block of bytes to another byte array using the System.Buffer class[^].
Of course, you can still use pointers and allocate blocks of memory in C#. But typically this is not required, and generally frowned on since it's usually a better practice to let the CLR manage the memory allocations and deallocations for you.
|
|
|
|
|
Anybody has a link to an article where I can find all the possible mappings between C# and C types in order to correctly declare them using DllImportAttribute?
I am looking for types like pointer types, often used to return data to the caller.
Thanks all.
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
|
|
|
|
|
|
Hi to all,
I am facing really strange problem. Could you please help me out from that?
LET me describe my requirement.
-------------------------------------------------------------------------------
We have list of "projects" which has some role like - PM, PL, TL, Developer, Tester etc. and absence of any of the person for the particular role, i have to assign other person, which has same role, in the project.
ie database is like this,
PM PL DEV TESTER
Project1 pml pl1 dev1,dev2 t1
Project2 pm9 pl10 dev18,dve20 t3,t10 etc..
PM = pm1,pm5,pm10,pm12 ect..
PL = pl1,pl11,pl10 etc...
so after setting back up of all projects, i have "save" button which save all the projects‘ back up in one table.
-------------------------------------------------------------------------
let's move on GUI...
I have one dropdownList - ddl which has roles (PM,PL,TL etc..)
and in datagrid i have 3 cols
1) Label - project name
2) TextBox - Person who is currently assign the role listed in dropdownList - ddl
3) ListBox - All the person who has same role in database listed in dropdownList - ddl
ie if i select TL in dropdownList, Datagrid shows,
1) all projects 2) person assign TL for the project. 3) all the person who are TL
I have a SAVE button which save all the projects backup at once.
------------------------------------------------------------------------------
To bind the Datagrid, i have use..
**************
asp:Label Runat=server id =name Text='%# DataBinder.Eval(Container,"DataItem.Name")%'
asp:TextBox text= '%# DataBinder.Eval(Container.DataItem,"Asigned Role") %'
Note - this two control bind by DataSet which returns “Project Name” and “Person Name”
***************
asp:ListBox Runat=server id ="ddl1" DataSource='%# getallData1() %' DataTextField="AllRoles" DataValueField="AllRoles" SelectionMode=Multiple
this is i dynamically bind with function "getallData1" which retunrs DataTable with one column - All person who is TL.
---------------------------------------------------------------------------
On save button i wrote code like
***********************************
private void Button1_Click(object sender, System.EventArgs e)
{
ArrayList arr = new ArrayList();
foreach (DataGridItem dgi in DataGrid1.Items)
{
Label lb = (Label) (dgi.Cells[0].Controls[1]);
TextBox tb = (TextBox) (dgi.Cells[2].Controls[1]);
ListBox lb1 = (ListBox) (dgi.Cells[1].Controls[1]); arr.Add(lb.Text.ToString());
arr.Add(tb.Text);
for (int i=0;i < lb1.Items.Count;i++)
{
if (lb1.Items[i].Selected==true) arr.Add(lb1.SelectedItem.Text);
}
}
ListBox1.DataSource = arr;
ListBox1.DataBind();
}
-------------------------------------------------
Right now i want to list all items in LISTBOX1 which has FirstRow as Project NAme, SecondRow TL Name, ThirdRow Backup of TL / BackUp of TLs
---------------------------------------------------
So, main problem is that.. I can access Label – Project Name, TextBox – Person name. But I can’t access the selected Value of Listbox in DataGrid. It always gives me all items as deselected.
Can any one tell me how to get all the records which I selected in Listbox?
Thanks in advance.
Bye.
|
|
|
|
|
I think I understand your problem. To sum all of it up, you want to access the new selected value in the ListBox. I am using a GridView in this code sample but it should work about the same. Instead of using strings with "," you could add straight into your array. Tell me how it works
protected void btnRun_Click(object sender, EventArgs e)
{
int intRowCount = GridView1.Rows.Count - 1;
string strDDLVals = "";
string strLBVals = "";
for (int i = 0; i < intRowCount; i++)
{
strDDLVals += ((DropDownList)GridView1.Rows[i].FindControl ("ddl1")).SelectedValue + ",";
strLBVals += ((ListBox)GridView1.Rows[i].FindControl("ListBox1")).SelectedValue + ",";
}
strLBVals.TrimEnd(',');
strDDLVals.TrimEnd(',');
}
|
|
|
|
|
It's working.....
Thank you very much
|
|
|
|
|
Hi to all,
I am facing really strange problem. Could you please help me out from that?
LET me describe my requirement.
-------------------------------------------------------------------------------
We have list of "projects" which has some role like - PM, PL, TL, Developer, Tester etc. and absence of any of the person for the particular role, i have to assign other person, which has same role, in the project.
ie database is like this,
PM PL DEV TESTER
Project1 pml pl1 dev1,dev2 t1
Project2 pm9 pl10 dev18,dve20 t3,t10 etc..
PM = pm1,pm5,pm10,pm12 ect..
PL = pl1,pl11,pl10 etc...
so after setting back up of all projects, i have "save" button which save all the projects‘ back up in one table.
-------------------------------------------------------------------------
let's move on GUI...
I have one dropdownList - ddl which has roles (PM,PL,TL etc..)
and in datagrid i have 3 cols
1) Label - project name
2) TextBox - Person who is currently assign the role listed in dropdownList - ddl
3) ListBox - All the person who has same role in database listed in dropdownList - ddl
ie if i select TL in dropdownList, Datagrid shows,
1) all projects 2) person assign TL for the project. 3) all the person who are TL
I have a SAVE button which save all the projects backup at once.
------------------------------------------------------------------------------
To bind the Datagrid, i have use..
**************
<asp:label runat="server" id="name" text="<%# DataBinder.Eval(Container,"DataItem.Name")%>">
<asp:textbox text="<%# DataBinder.Eval(Container.DataItem,"Asigned Role") %>" id="AssignRole" runat="server">
Note - this two control bind by DataSet which returns “Project Name” and “Person Name”
***************
<asp:listbox runat="server" id="ddl1" datasource="<%# getallData1() %>" datatextfield="AllRoles" datavaluefield="AllRoles" selectionmode="Multiple">
this is i dynamically bind with function "getallData1" which retunrs DataTable with one column - All person who is TL.
---------------------------------------------------------------------------
On save button i wrote code like
***********************************
private void Button1_Click(object sender, System.EventArgs e)
{
ArrayList arr = new ArrayList();
foreach (DataGridItem dgi in DataGrid1.Items)
{
Label lb = (Label) (dgi.Cells[0].Controls[1]);
TextBox tb = (TextBox) (dgi.Cells[2].Controls[1]);
ListBox lb1 = (ListBox) (dgi.Cells[1].Controls[1]); arr.Add(lb.Text.ToString());
arr.Add(tb.Text);
for (int i=0;i < lb1.Items.Count;i++)
{
if (lb1.Items[i].Selected==true) arr.Add(lb1.SelectedItem.Text);
}
}
ListBox1.DataSource = arr;
ListBox1.DataBind();
}
-------------------------------------------------
Right now i want to list all items in LISTBOX1 which has FirstRow as Project NAme, SecondRow TL Name, ThirdRow Backup of TL / BackUp of TLs
---------------------------------------------------
So, main problem is that.. I can access Label – Project Name, TextBox – Person name. But I can’t access the selected Value of Listbox in DataGrid. It always gives me all items as deselected.
Can any one tell me how to get all the records which I selected in Listbox?
Thanks in advance.
Bye.
|
|
|
|
|
Hi all,
Has any one integrated MSN Messenger with their chat applications?
IF yes how do i do that?
Any links or pointers in this context will be appreciated.
Thanks & Regards,
Pramod
"Everyone is a genius at least once a year"
|
|
|
|
|
Hi,
How can i append elements to the root of a xmldocument using a method?
This was my previous method:
public void WritingToXMLDoc(string elementString, string writeToXMLDoc)
{
this.writer.WriteElementString(elementString, writeToXMLDoc);
}
But now, im coverting everything to xmldocument.
Thanks in advance!
|
|
|
|
|
Do a bit reading in the docs. MSDN - Process XML Data Using the DOM Model[^]
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Hi,
Im like 4 hours on msdn libraries and google.
But i havent found what i was looking for.
Hope somebody could help me with this.
|
|
|
|
|
Yustme wrote: Im like 4 hours on msdn libraries and google. But i havent found what i was looking for.
Then you should definitely train using the docs.
Since we have marvelous weather today in germany and I'm in a really good mood, here the code that should do what you want. Read the link I provided before and the docs of the involved classes to learn more.
XmlDocument doc = new XmlDocument();
doc.Load("file.xml");
public void WritingToXMLDoc(string elementString, string writeToXMLDoc)
{
XmlElement element = doc.CreateElement(elementString);
XmlText text = doc.CreateTextNode(writeToXMLDoc);
element.AppendChild(text);
doc.DocumentElement.AppendChild(element);
}
doc.Save("file.xml");
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Hi,
Am i glad that ur in a good mood.
That helped, thank you !
|
|
|
|
|
See here[^] maybe it is some helpful to you
|
|
|
|
|
hi,
is it possible to copy an already existing database(db1.mdb)in vb2005 and show this copy on the grid, add or delete rows in it, but these chances happen in the copy for example db2.mdb. So db2.mdb doesn't exist before you run the c# program.
i would like to make different files for everyday so i can know what i changed yesterday and today
tips on this subject are always handy,
for now my program saves everyting in one file but i need to change that
plz help
thx
|
|
|
|
|
File.Copy("db1.mdb", "db2.mdb", true);
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
i see, thats how i copy one database in the other, but db2.mdb does not exitst, i need to make a new one for every day.
ill give an example how i would like to use it.
in access i make one database: db1.mdb in this i write recepst for 100 different cakes
in c# program i can see all recepst an add one or delete or i can register that i have used nr 33 and 55, all these changes are not made in the main database db1.mdb, but in a copy of it (day1.mdb) this one needs to be generated by c#.
Day 2 i open the c# program again and i get my 100 recepst form db1.mdb again, if i make changes here they will be saved in another copy of it (day2.mdb) and so on and so on.
my problem is that i dont know how to make a new database with my c# program so i become day1.mdb, day2.mdb, day3.mdb, day...
thx
|
|
|
|
|
faladrim wrote: i see, thats how i copy one database in the other, but db2.mdb does not exitst, i need to make a new one for every day
So what.? Don't hard code the destination file name but generate in a appropriate way.
string dest = "day" + DateTime.Now.DayOfYear.ToString() + ".mdb";
File.Copy("db1.mdb", dest, true);
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
and what is the defintion of file?
is that the same as my connectionstring?
|
|
|
|
|
File is a class in the System.IO namespace that exposes amongst others a static Copy method.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|