Click here to Skip to main content
15,895,799 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to get all environment variable of a process Pin
Luc Pattyn19-Jul-07 8:36
sitebuilderLuc Pattyn19-Jul-07 8:36 
GeneralRe: How to get all environment variable of a process Pin
SteveA6920-Jul-07 1:58
SteveA6920-Jul-07 1:58 
GeneralRe: How to get all environment variable of a process Pin
Luc Pattyn20-Jul-07 3:47
sitebuilderLuc Pattyn20-Jul-07 3:47 
GeneralRe: How to get all environment variable of a process Pin
SteveA6920-Jul-07 11:42
SteveA6920-Jul-07 11:42 
GeneralRe: How to get all environment variable of a process Pin
Luc Pattyn20-Jul-07 16:01
sitebuilderLuc Pattyn20-Jul-07 16:01 
GeneralRe: How to get all environment variable of a process Pin
SteveA6920-Jul-07 23:47
SteveA6920-Jul-07 23:47 
GeneralRe: How to get all environment variable of a process Pin
Luc Pattyn21-Jul-07 0:55
sitebuilderLuc Pattyn21-Jul-07 0:55 
GeneralRe: How to get all environment variable of a process Pin
SteveA6923-Jul-07 2:06
SteveA6923-Jul-07 2:06 
Hi Luc,

either I don't understand your replies, or you didn't understand my problem.

The programs which use the environment variables which I want to get are not my programs. So I don't know which environment variables they use. So I can't set this in a DOS-Box.

Another example:
You write a program. This program do nothing when it starts.
You write a methode which create a new environment variable, if a button is pushed. This environment variable is only guilty in your program, process, session.

Now you start your program but you don't push the button.
I start than the process explorer on the same maschine and search for your program/process.
The process explorer shows me all the environment variable which your program use.
I think these are the one, which stand in the user and system environment.

Then I start my special program.
This program should do the same as the process explorer.
My program shows me the same environmment variables which your program use.

Then you push the button. Your methode create a new environment variable.

I refresh the view of the process explorer. The process explorer shows me now one environment variable more. It shows me your new created variable.

I refresh the view of my program, but my program don't show me the new environment variable. Why?

I think that the dotnet framework cannot show me the variable, too.
I think I need a winapi-function.

For example to get the parent id of a process I used the createtoolhelp32snapshot-function. So I think I need a winapi function too.

Or did I do a mistake ?
My code snippet is the following.

private void button1_Click(object sender, EventArgs e)
{
listView1.View = View.Details;
listView1.Sorting = SortOrder.Ascending;
listView1.FullRowSelect = true;

listView1.Columns.Add("Name", 150, HorizontalAlignment.Left);
listView1.Columns.Add("Wert", 450, HorizontalAlignment.Left);


ListViewItem oItem;
listView1.Items.Clear();

Process[] localByName = Process.GetProcessesByName(textBox1.Text);
if (localByName.Length > 0)
{
Process oProcess = localByName[0];
foreach (DictionaryEntry de in _
oProcess.StartInfo.EnvironmentVariables)
{
oItem = listView1.Items.Add(de.Key.ToString());
oItem.SubItems.Add(de.Value.ToString());
}
}
}
To use the snippet you need on the form a listView, a pushbutton and a textbox-object.

If I haven't make an error in my code, do you have a code snippet who can read the environment variable, which is created in your example program ?

Thanks
Stephan
GeneralRe: How to get all environment variable of a process Pin
Luc Pattyn23-Jul-07 3:00
sitebuilderLuc Pattyn23-Jul-07 3:00 
GeneralRe: How to get all environment variable of a process Pin
SteveA6923-Jul-07 22:57
SteveA6923-Jul-07 22:57 
QuestionIs there a way to sort Listview columns numericly? Pin
Minosknight19-Jul-07 7:55
Minosknight19-Jul-07 7:55 
AnswerRe: Is there a way to sort Listview columns numericly? Pin
BoneSoft19-Jul-07 8:08
BoneSoft19-Jul-07 8:08 
GeneralRe: Is there a way to sort Listview columns numericly? Pin
Minosknight19-Jul-07 8:11
Minosknight19-Jul-07 8:11 
QuestionHow to use Backgroundworker for data transer? Pin
Khoramdin19-Jul-07 6:40
Khoramdin19-Jul-07 6:40 
AnswerRe: How to use Backgroundworker for data transer? Pin
Manas Bhardwaj19-Jul-07 7:05
professionalManas Bhardwaj19-Jul-07 7:05 
Questionproblems with incoming messages Pin
donjubs19-Jul-07 6:34
donjubs19-Jul-07 6:34 
AnswerRe: problems with incoming messages Pin
Judah Gabriel Himango19-Jul-07 7:41
sponsorJudah Gabriel Himango19-Jul-07 7:41 
GeneralRe: problems with incoming messages Pin
donjubs19-Jul-07 7:51
donjubs19-Jul-07 7:51 
GeneralRe: problems with incoming messages Pin
Judah Gabriel Himango19-Jul-07 8:05
sponsorJudah Gabriel Himango19-Jul-07 8:05 
GeneralRe: problems with incoming messages Pin
donjubs19-Jul-07 9:13
donjubs19-Jul-07 9:13 
GeneralRe: problems with incoming messages Pin
Judah Gabriel Himango19-Jul-07 9:46
sponsorJudah Gabriel Himango19-Jul-07 9:46 
GeneralRe: problems with incoming messages Pin
donjubs19-Jul-07 9:51
donjubs19-Jul-07 9:51 
GeneralRe: problems with incoming messages Pin
Judah Gabriel Himango20-Jul-07 7:25
sponsorJudah Gabriel Himango20-Jul-07 7:25 
GeneralRe: problems with incoming messages Pin
donjubs20-Jul-07 12:35
donjubs20-Jul-07 12:35 
GeneralRe: problems with incoming messages Pin
Judah Gabriel Himango21-Jul-07 11:56
sponsorJudah Gabriel Himango21-Jul-07 11:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.