04-04-2006 07:27 PM
04-04-2006 07:38 PM
Sorry, not sure what key I hit...
Anyhow, a routine to check if the executable is running on the C drive or on a network drive:
GetProjectDir (currentFolder);
if (strstr (currentFolder, "c:\\"))
{
// run local stuff
}
else
{
// run network stuff
}
This works fine when running under debug mode, but always executes the "else" code after compiled.
Any ideas?
04-05-2006 01:52 AM
Hi, cpoore, have you considered using SplitPath function? It can return the drive only so that you can specifically test its value instead of searching for the occurrence of a string.
In case of physical local drive the function returns the drive name and the colon without the backslash, the same in case of a network drive mapped to a virtual drive in the computer. In case of a real network drive (e.g. \\RemoteComputer\\myprogram.exe) the function returns an empty string as the drive name.
04-05-2006 07:20 AM
Are you sure the drive letter is always lower case?
if (strstr(currentFolder, "c:\\") || strstr(currentFolder, "C:\\"))
might be better, or you could use the CVI FindPattern() function, which can do case-insensitive searching.
04-05-2006 11:36 AM
probably TAB followed by Space. Happens all the time 😉
@cpoore wrote:
Sorry, not sure what key I hit...
04-05-2006 12:31 PM
04-05-2006 06:07 PM - edited 04-05-2006 06:07 PM
Would it be simpler to use the Utility Library function GetDrive()?
Perhaps something like this:
GetProjectDir (currentFolder);
SetDir (currentFolder); // to be sure
GetDrive (&driveNumber, &numberOfDrives);
Message Edited by cdk52 on 04-06-2006 10:27 AM
04-05-2006 09:11 PM
Yes! I did find that...
GetDrive (&driveNum, &numDrives);
if (driveNum == 2)
{
// using local C drive
}
else
{
// using networked drive
}
But the SplitPath function is still cool.