Retrieving values of another program's variables?

Hello,
I am building a .dll plugin for a different application.

This .dll requires that I retrieve several of the program's current running environment variables.

How would I go about that (if I know what the names of the variables are supposed to be?)

Thanks in advance.

-Dan
LVL 3
SuperMarioAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

chensuCommented:
GetEnvironmentVariable
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SuperMarioAuthor Commented:
Ah...
I am guessing that will work with a pointer to a CWinApp object.

Unfortunately I'm not sure how to get a CWinApp from simply the application name.

Help?

-D
0
chensuCommented:
What are you talking about?
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

SuperMarioAuthor Commented:
If I can get a CWinApp object pointing to the application I want to retrieve variables from, I can probably do something like:

CWinApp *targetApp = GetAppFunction();
targetApp->GetEnvironmentVariable(x,y,z);

Am I correct?

-D
0
chensuCommented:
GetEnvironmentVariable is a Win32 API function.
0
SuperMarioAuthor Commented:
I see.

I know this should now be moved to the MFC topic area, but I figured there would be an easier way.

Can you give me some code for 50 more points, that will get environment variables from a program called MyProgram?

Thank you!

-Dan
0
chensuCommented:
Getting environment variable has nothing to do with CWinApp. Simply call GetEnvironmentVariable. For example,

TCHAR lpszBuf[128];
::GetEnvironmentVariable(_T("ENVNAME"), lpszBuf, sizeof(lpszBuf) / sizeof(TCHAR));
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Components

From novice to tech pro — start learning today.