[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 157
  • Last Modified:

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
0
SuperMario
Asked:
SuperMario
  • 4
  • 3
1 Solution
 
chensuCommented:
GetEnvironmentVariable
0
 
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
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
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

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now