PDA

View Full Version : How to determine if a drive is local?



NewsArchive
01-16-2010, 02:48 AM
I need to determine whether a drive is "local" to a machine, so I can
ascertain whether the install will offer to run an app as a program or
a service.

Using GetDriveType() can sometimes return DRIVE_NO_ROOT_DIR, even if
it's a local disk.

Is there a better way to determine the eligibility for a program to be
installed as a service?

Jeff Slarve

NewsArchive
01-16-2010, 02:49 AM
Jeff,

> I need to determine whether a drive is "local" to a machine, so I can
> ascertain whether the install will offer to run an app as a program or
> a service.

If I recall correctly there is an API call that will take a mapped
drive and return a UNC. The server portion could be compared to the
current machines name - but Friedrich probably has some better way!<g>

--
Lee White

Enroll Today at http://CWaddons.com

Reports....: http://www.cwaddons.com/products/rpm/
Free Review: http://www.clarionmag.com/cmag/v11/v11n06rpm.html
Faxing.....: http://www.cwaddons.com/products/afe/

NewsArchive
01-16-2010, 02:49 AM
About 10 years ago or more, I was looking at WNetGetUniversalName. Is
that what you mean?

I had dropped the idea of using it because it requires admin rights.

Now that I am certain that it's an admin running the code, I reckon it
could be of use.

Will check it out.

Thanks.

Jeff Slarve

NewsArchive
01-16-2010, 02:50 AM
Haven't tried within SetupBuilder, but I use GetDriveTypeA within some apps.

http://support.microsoft.com/kb/161300

jf

NewsArchive
01-16-2010, 02:50 AM
I was using that, but I guess it was incorrectly.

I was following someone's example where they passed the entire path
name (not just the root). Now that I just pass the 'c:\', it works as
expected.

Thanks for making me re-look. Maybe that's all I need to do now.

Jeff Slarve

NewsArchive
01-16-2010, 02:51 AM
I just opened one source where I use it and found:


ThePath=UPPER(command('0'))
zz#=fn_split(ThePath,TheDrive,TheDir,TheName,TheEx t)

pathstring=TheDrive&TheDir
ThePath=TheDrive&TheDir
TheStartupDrive=TheDrive
setpath(pathstring)
GLO:BaseDataPath=ThePath
GLO:DataPath=ThePath&'DATA\' !establish default data path
zy#=len(clip(TheDrive))
zdrive=TheDrive
if sub(ZDrive,zy#,1)<>'\'
zDrive=zDrive&'\'
END ! IF
GLO:ProgramDriveType=getdrivetype(zDrive)
if GLO:ProgramDriveType=4
GLO:NetworkProgramDrive=1
end ! if
IF GLO:ProgramDriveType=2
GLO:IsThumbDrive=1
end ! if
Zdrive=''

jane

NewsArchive
01-16-2010, 02:51 AM
Thanks Jane

Jeff Slarve

NewsArchive
01-16-2010, 02:52 AM
Sorry... quick response pasted... just to agree that drive letter alone
seems to be what it wants.

jf

NewsArchive
01-16-2010, 02:56 AM
Hi Jeff,

> I was following someone's example where they passed the entire path
> name (not just the root). Now that I just pass the 'c:\', it works as
> expected.

To do this from the install, just use the "Get System Info (Drive Type)"
script function.

Friedrich

NewsArchive
01-17-2010, 04:29 AM
Thanks Friedrich. I had tried that, but since I was passing the same
data, it was "failing" too<g>

Jeff Slarve