Jump-start your project by learning from devs who
write Windows drivers and file systems every day.
Take an OSR seminar!

OSR is Hiring! Click here to find out more.

Upcoming OSR Seminars:
Kernel Debugging & Crash Analysis for Windows Lab, Santa Clara, CA 9-13 September, 2013
Upcoming OSR Seminars:
Windows Internals & Software Drivers Lab, Santa Clara, CA 16-20 September, 2013
Writing WDF Drivers for Windows Lab, Boston/Waltham, MA 7-11 October, 2013
Developing File Systems for Windows, Seattle, WA 5-8 November, 2013


Go Back   OSR Online Lists > ntdev
Welcome, Guest
You must login to post to this list
  Message 1 of 4  
20 Aug 12 12:41
Dhaval Vasu
xxxxxx@hotmail.com
Join Date: 25 Sep 2011
Posts To This List: 34
Boot device dos name

How to get boot device dos name in windows xp, vista+? I need boot device, not windows or system. In application, not a driver. Dos name like C:\ , so I could use win api to access files. Any help appreciated.
  Message 2 of 4  
20 Aug 12 15:00
Alex Grig
xxxxxx@broadcom.com
Join Date: 14 Apr 2008
Posts To This List: 1866
RE: Boot device dos name

SystemDrive environment variable
  Message 3 of 4  
20 Aug 12 15:45
raj r
xxxxxx@gmail.com
Join Date: 20 Jul 2006
Posts To This List: 240
Re: Boot device dos name

On 8/20/12, xxxxx@hotmail.com <xxxxx@hotmail.com> wrote: > How to get boot device dos name in windows xp, vista+? > I need boot device, not windows or system. In application, not a driver. > Dos name like C:\ , so I could use win api to access files. > > Any help appreciated. F:\>echo %systemdrive% C: F:\> %SystemDrive% The %SystemDrive% variable is a special system-wide environment variable found on Microsoft Windows NT and its derivatives. Its value is the drive upon which the system folder was placed. Also see next item. The value of %SystemDrive% is in most cases C:. http://en.wikipedia.org/wiki/Environment_variable // getenv.cpp : Defines the entry point for the console application. // #include "stdafx.h" int _tmain(int argc, _TCHAR* argv[]) { size_t Result; _TCHAR* Buffer; printf( "lets get the boot device dos name and print it to screen\n" ); if ( ( Result = GetEnvironmentVariable( L"SystemDrive", NULL, 0 )) != 0 ) { Buffer = (_TCHAR*) malloc( Result+10 ); if ( ( Result = GetEnvironmentVariable( L"SystemDrive", Buffer, Result+10 ) ) != 0 ) { printf( "Boot Device Dos Name Is %s\n",Buffer ); free( Buffer ); ExitProcess ( 0x500d ); } } printf( "Environment Variable %%SystemDrive%% Not Available\n" ); ExitProcess ( 0xe5505 ); return 0; }
  Message 4 of 4  
21 Aug 12 04:33
Dhaval Vasu
xxxxxx@hotmail.com
Join Date: 25 Sep 2011
Posts To This List: 34
RE: Boot device dos name

Thanks sir! What about if there are more than one OS installed. System driver depends on what operating system is loaded, but not partition table configuration. I need to read boot.ini file. In windows XP when you open system properties, then boot parameters window, you can see default operating system which is loaded. Windows reads partition table, convert partition number to device name like C:\ and reads file. Same will work for vista+ for bcd storage.
Posting Rules  
You may not post new threads
You may not post replies
You may not post attachments
You must login to OSR Online AND be a member of the ntdev list to be able to post.

All times are GMT -5. The time now is 02:09.


Copyright ©2012, OSR Open Systems Resources, Inc.
Based on vBulletin Copyright ©2000 - 2005, Jelsoft Enterprises Ltd.
Modified under license