|
Hi,
> 1) use my own environment vars in links and shortcuts
> (e.g. Target and Start In fields in a shortcut's property dialog
Surround the variable name with percent symbols; e.g.
%PROJECTS%\SomeTool.exe %LAUNCH_ARGS%
Also, if the variable represents a path and it may have a space in it I'd recommend changing the above to:
"%PROJECTS%\SomeTool.exe" %LAUNCH_ARGS%
> 2) use my own environment vars in batch files
Same again.
> 3) set my own environment vars programmatically (from VC++)
You can use the SetEnvironmentVariable API but this function only sets the variable for the current process (and any child processes that you may launch that inherit the current environment).
To set persistent environment variables you have to save them in the registry on NT/2K/XP and in AUTOEXEC.BAT on 95/98/Me. The rest of these notes are for NT/2K/XP only.
There are three types of environment variables: user, system and volatile.
The system variables are loaded first and are the same for every user on the system. They are stored as values of this registry key:
[HKLM\System\CurrentControlSet\Control\Session Manager\Environment]
If the value is a straight string the registry value type is REG_SZ, but if the value contains another environment variable name (in percent symbols) the value type is REG_EXPAND_SZ.
Next come the user environment variables. These are per user (duh!) and are stored in each user's registry hive under:
[HKCU\Environment]
These follow the same rules as the system variables; they can also refer to a system variable name (in percent symbols).
The final category is volatile variables; these are also per-user but are not saved between logon sessions; the system stores things such as the current logon server and domain name here. They are stored in:
[HKCU\Volatile Environment]
All three types are joined to create the final environment block your process is started with.
BTW, if you do create a tool to modify the environment and you want a running process (such as Explorer) to pick up the changes, you have to broadcast a WM_SETTINGSCHANGE message to notify them. A snippet of C++ does this:
const DWORD dwTimeout= 3000;
DWORD dwResult= 0;
SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE,
0, (LPARAM)_T("Environment"), SMTO_NORMAL,
dwTimeout, &dwResult);
Hope this helps.
Regards,
John Bates.
|
|
|
|
|
Thanks all. I got my shortcuts running with %My_ROOT%.
I now must fix my CoolProg.exe code so that when I supply a configuration file as an argument, and that configuration file itself uses the My_ROOT variable within, the environment variable is correctly interpreted as the full path (value).
Johnny
|
|
|
|
|
|
Thanks, I didn't know about the ExpandEnvironmentStrings() and therefore wrote my own string parser/environment variable expander (using the GetEnv() function and a while loop)
I think I will use the canned ExpandEnvironmentStrings() function.
HOWEVER, I am noticing a problem with the CWinApp::ParseCommandLine()
Maybe it's just me, but when I do the following
%My_ROOT%\bin\myapp.exe %My_ROOT%\config\myconfigs.prj
The argument "myconfigs.prj" doesn't get its pathname resolved -- it passes down to the lower underlyings of CWinApp::ParseCommandLine() as the literal string %My_ROOT%\config\myconfigs.prj and tries to open that file, which fails.
Any more guidance??
Thanks - Happy Independence Day!
Johnny
|
|
|
|
|
Try something like this (inside your InitInstance() function):
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
_TCHAR szExpanded[MAX_PATH+1] = {0};
ExpandEnvironmentStrings(cmdInfo.m_strFileName, szExpanded, MAX_PATH);
Then, instead of cmdInfo.m_strFileName , use szExpanded ;
I prefer to wear gloves when using it, but that's merely a matter of personal hygiene
[Roger Wright on VB]
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.
[Rich Cook]
|
|
|
|
|
How to Insert/Delete/Modify an entry in a Windows 2000 DNS Server with visual C++. Is there some API's for that purpouse. I've found some VBS's form Microsoft, but i haven't any clue how to convert in to VC++
Tkanks
|
|
|
|
|
You think MS could have provided a way to setup ASP.NET after your installed the .NET framework. I came back to my ASP.NET works after a break and IIS would not work at all, just blank error boxes. So I reinstalled IIS. Now I have to figure out how to install the .NET associations for IIS
Matt Newman
"Two things have come out of Berkley, Unix and Acid, we do not belive this to be a coincidence" Linux sucks twice as fast and 10 times more reliably, and since you have the source, it's your fault. -Ca1v1n
Post best viewed with lynx
|
|
|
|
|
Try aspnet_regiis.exe
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
|
|
|
|
|
Richard Deeming wrote:
Try aspnet_regiis.exe
I just found that. You would think that they would put this somewhere on the installing ASP.NET on IIS 5 page, but that would make sense and why would they do that.
Thanks for the response though
Matt Newman
"Two things have come out of Berkley, Unix and Acid, we do not belive this to be a coincidence" Linux sucks twice as fast and 10 times more reliably, and since you have the source, it's your fault. -Ca1v1n
Post best viewed with lynx
|
|
|
|
|
Hello,
Is it possible that I can have a process running on Windows XP Home that does not appear in the Windows Task Manager?
If so, how can I detect such processes?
Thanks,
-Me!
|
|
|
|
|
Anonymous wrote:
Is it possible that I can have a process running on Windows XP Home that does not appear in the Windows Task Manager?
Not AFAIK. That used to be a feature of pre-stone age Win9x OS
Regards,
Venet.
Donec eris felix, multos numerabis amicos.
|
|
|
|
|
Yes, it is possible but I hope Mircrosoft will fix it soon! I know of no way of detecting it but if it is a problem to you then contact me and we will find some solution.
jhaga
CodeProject House, Paul Watson wrote:
...and the roar of John Simmons own personal Nascar in the garage. Meg flitting about taking photos.Chris having an heated arguement with Colin Davies and .S.Rod. over egian values. Nish manically typing *censur*. Duncan racing around after his pet *c.* Michael Martin and Bryce loudly yelling *c.* C.G. having a fit as Roger Wright loads up *c.* . Anna waving her *c.* and Deb scoffing chocolates in the corner.
...Good heavens!
|
|
|
|
|
jhaga wrote:
Yes, it is possible but I hope Mircrosoft will fix it soon! I know of no way of detecting it but if it is a problem to you then contact me and we will find some solution.
Mind sharing it please?
Regards,
Venet.
Donec eris felix, multos numerabis amicos.
|
|
|
|
|
If you use VB:
To hide the program from the Taskmanager write the below code in the form load.
App.Taskvisible = False
[Edit: ok, you will see it in Processes but by selecting a strange name for it, it will be difficult to find]
http://www.codeproject.com/useritems/PreventClose.asp[^]
jhaga
CodeProject House, Paul Watson wrote:
...and the roar of John Simmons own personal Nascar in the garage. Meg flitting about taking photos.Chris having an heated arguement with Colin Davies and .S.Rod. over egian values. Nish manically typing *censur*. Duncan racing around after his pet *c.* Michael Martin and Bryce loudly yelling *c.* C.G. having a fit as Roger Wright loads up *c.* . Anna waving her *c.* and Deb scoffing chocolates in the corner.
...Good heavens!
|
|
|
|
|
jhaga wrote:
[Edit: ok, you will see it in Processes but by selecting a strange name for it, it will be difficult to find]
http://www.codeproject.com/useritems/PreventClose.asp[^]
I'm gonna check this article tomorrow, but if it works it changes many things.
Thanks
<edit>
It does work, no trace of the process in Task Manager, however it is still shown in the Process Explorer (sysinternals)
Thanks for the link.
</edit>
Regards,
Venet.
Donec eris felix, multos numerabis amicos.
|
|
|
|
|
Anonymous wrote:
how can I detect such processes
Use Process Viewer in Visual Studio.
"The Lion shall lie down with the Lamb; but the Lamb will not get much sleep..." Lazarus Long
|
|
|
|
|
I've installed a new harddrive but I can't see it in My Computer. It is visible in BIOS and Device Manager. It is not formated as many of my friends say I have to do. But HOW?
In Disk Manager there is no way to format the drive (what I can see)!
I'm running Windows 2000 Server
Rickard Andersson
Here is my card, contact me later!
UIN: 50302279
E-Mail: nikado@pc.nu
Interests: C++, ADO, SQL, Winsock, 0s and 1s
|
|
|
|
|
You may have to partition the drive first.
Right-click on the drive in the bottom pane in the Disk Management applet, and select 'Create Partition' (I think thats what the option is, I don't have an blank drive handy)
Searching the web without Google is like straining sewage with your teeth. Userfriendly, 2003/06/07
|
|
|
|
|
Here is a screenshoot in Disk Manager where I try to do what you say: http://duden.mine.nu/scr.jpg[^]
What am I doing wrong? Or am I clicking in the wrong place?
Rickard Andersson
Here is my card, contact me later!
UIN: 50302279
E-Mail: nikado@pc.nu
Interests: C++, ADO, SQL, Winsock, 0s and 1s
|
|
|
|
|
Rickard Andersson18 wrote:
http://duden.mine.nu/scr.jpg[^]
I don't know why a login dialog box is showed when I want to view that picture!
But press Enter and you'll see it!
Rickard Andersson
Here is my card, contact me later!
UIN: 50302279
E-Mail: nikado@pc.nu
Interests: C++, ADO, SQL, Winsock, 0s and 1s
|
|
|
|
|
You don't have the permissions set properly to allow public access - we can't see the screenshot.
"The Lion shall lie down with the Lamb; but the Lamb will not get much sleep..." Lazarus Long
|
|
|
|
|
And did you click enter as I said?
I do get that screen too, and I just press enter and the picture is shown!
Rickard Andersson
Here is my card, contact me later!
UIN: 50302279
E-Mail: nikado@pc.nu
Interests: C++, ADO, SQL, Winsock, 0s and 1s
|
|
|
|
|
Yup, I clicked enter as instructed. You can see it because you have an account on the server - I don't. Make sure the file has IUSR_YOURMACHINE in its list of authorized users, and that the folder is enabled for websharing.
"The Lion shall lie down with the Lamb; but the Lamb will not get much sleep..." Lazarus Long
|
|
|
|
|
Roger Wright wrote:
Make sure the file has IUSR_YOURMACHINE in its list of authorized users
I'd right-clicked on the file and choosed Properties->File Security->Anonymious access and authentication control and pressed the button named Edit. Then I see Anonymous access is marked and that account for anonymous access is IUSR_MALIN (my computer name is Malin).
So,, why doesn't it work?
I have an exe in the dir also, http://duden.mine.nu/vncviewer.exe which I can download without any login.
Rickard Andersson
Here is my card, contact me later!
UIN: 50302279
E-Mail: nikado@pc.nu
Interests: C++, ADO, SQL, Winsock, 0s and 1s
|
|
|
|
|
Ok, I wasn't able to get the screenshot either, but recently installed few drives on my Win2k machine and have a fair idea of the steps.
Go to Start and Run --> compmgmt.msc and OK.
Go to Disk Management -> Right click on the SHADED area and go to Create Partiton.
Then you should see the drive on the Explorer, just format it and that should do.
Regards,
Venet.
Donec eris felix, multos numerabis amicos.
|
|
|
|