320x100
|
Run the application at Windows startup를 하기 위해서 Window의 System32폴더에 접근할 필요가 있었습니다.
그런데 WINNT의 경우는 C:\WINNT\System32이고
XP의 경우 C:\WINDOWS\System32입니다. 윈도우폴더가 다르죠^^
if (Directory.Exists(drive + "WINDOWS\\System32")
{
}
if Directory.Exists(drive + "WINDOWS NT\\System32"))
{
}
우와 같이 Directory.Exists를 이용하여 해당 폴더가 있는 지 확인하여 접근할 수 도 있지만, 그럴 필요가 없습니다.
Environment.SystemDirectory 를 이용하여 접근하면 바로 됩니다^^
using System;
using System.Collections.Generic;
using System.Text;
namespace GetEnvironmentInfo
{
class Program
{
/// <summary>
/// Mains the specified args.
/// </summary>
/// <param name="args">The args.</param>
static void Main(string[] args)
{
GetEnvironmentInfo();
}
/// <summary>
/// Gets the environment info.
/// </summary>
public static void GetEnvironmentInfo()
{
Console.WriteLine("CurrentDirectory: {0}", Environment.CurrentDirectory);
Console.WriteLine("MachineName: {0}", Environment.MachineName);
Console.WriteLine("OSVersion: {0}", Environment.OSVersion.ToString());
Console.WriteLine("SystemDirectory: {0}", Environment.SystemDirectory);
Console.WriteLine("UserDomainName: {0}", Environment.UserDomainName);
Console.WriteLine("UserInteractive: {0}", Environment.UserInteractive);
Console.WriteLine("UserName: {0}", Environment.UserName);
Console.WriteLine("CLRVersion: {0}", Environment.Version.ToString());
Console.WriteLine("WorkingSet: {0}", Environment.WorkingSet);
Console.WriteLine("ExpandEnvironmentVariables: {0}",
Environment.ExpandEnvironmentVariables("System drive: " +
"%SystemDrive% System root: %SystemRoot%"));
Console.WriteLine("GetLogicalDrives: {0}", String.Join(", ",
Environment.GetLogicalDrives()));
}
}
}
using System.Collections.Generic;
using System.Text;
namespace GetEnvironmentInfo
{
class Program
{
/// <summary>
/// Mains the specified args.
/// </summary>
/// <param name="args">The args.</param>
static void Main(string[] args)
{
GetEnvironmentInfo();
}
/// <summary>
/// Gets the environment info.
/// </summary>
public static void GetEnvironmentInfo()
{
Console.WriteLine("CurrentDirectory: {0}", Environment.CurrentDirectory);
Console.WriteLine("MachineName: {0}", Environment.MachineName);
Console.WriteLine("OSVersion: {0}", Environment.OSVersion.ToString());
Console.WriteLine("SystemDirectory: {0}", Environment.SystemDirectory);
Console.WriteLine("UserDomainName: {0}", Environment.UserDomainName);
Console.WriteLine("UserInteractive: {0}", Environment.UserInteractive);
Console.WriteLine("UserName: {0}", Environment.UserName);
Console.WriteLine("CLRVersion: {0}", Environment.Version.ToString());
Console.WriteLine("WorkingSet: {0}", Environment.WorkingSet);
Console.WriteLine("ExpandEnvironmentVariables: {0}",
Environment.ExpandEnvironmentVariables("System drive: " +
"%SystemDrive% System root: %SystemRoot%"));
Console.WriteLine("GetLogicalDrives: {0}", String.Join(", ",
Environment.GetLogicalDrives()));
}
}
}
Download Source Code
출력결과
MSDN 보기
http://msdn.microsoft.com/ko-kr/library/system.environment.systemdirectory(VS.80).aspx
|
반응형
'소프트웨어' 카테고리의 다른 글
엑셀 한칸에 두줄 넣는 방법 (1) | 2014.10.17 |
---|---|
MS 클라우드 경제성 기업의 활용 (2) | 2011.04.28 |
Parent Toolbar를 클릭해서 Mdi Child에 있는 함수를 호출하자 (9) | 2009.03.03 |
파라메터쿼리를 만들어주는 프로시져 (9) | 2009.02.24 |
C:\Microsoft.CSharp.targets 프로젝트 찾을 수 없습니다. (9) | 2009.02.17 |
댓글