473,503 Members | 1,712 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Code asking OS if a dir is network shared?

A few days ago I asked how to allow apps to run only on a stand-alone
machine, and not on a network or server, and got some great code for
determining OS version, etc.

However, one suggestion made was to "access the directory where the app is
running from and then ask the OS if the drive is a networked share.", but no
code example was given. I know how to find the app startup directory, but
how do I “ask the OS if the drive is a networked share."?? Does anybody have
coding for this? Since I will be checking this each time the app starts, I
hope to find a method that is fast, and does not require checking the startup
path, string by string, against a large collection.

Thanks to all who take time to help the rest of us!

Regards,
pcad1

Nov 16 '05 #1
1 1171
Hi,

You may want to use GetDriveType() Win32 API. Below is an example:

public class MainClass
{
[DllImport("kernel32.dll")]
public static extern int GetDriveType (string lpRootPathName);

public static void Main()
{
if (GetDriveType (@"F:\") == 4) // Remote/network drive
{
Console.WriteLine ("F: is a network mapped drive");
}
}
}

Hope this helps.

"pcad1" <pc***@discussions.microsoft.com> wrote in message
news:74**********************************@microsof t.com...
A few days ago I asked how to allow apps to run only on a stand-alone
machine, and not on a network or server, and got some great code for
determining OS version, etc.

However, one suggestion made was to "access the directory where the app is
running from and then ask the OS if the drive is a networked share.", but no
code example was given. I know how to find the app startup directory, but
how do I "ask the OS if the drive is a networked share."?? Does anybody
have
coding for this? Since I will be checking this each time the app starts, I
hope to find a method that is fast, and does not require checking the
startup
path, string by string, against a large collection.

Thanks to all who take time to help the rest of us!

Regards,
pcad1
Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4356
by: intl04 | last post by:
Are there any problems with multiple user access to the same Access database on a shared network drive? I have 'shared' chosen for 'default open mode'. As for the record locking properties, I...
3
13308
by: Bonj | last post by:
I need to write a windows service, and the only way it can access a shared drive on a file server on the network is if the installer is put in "User" mode - "LocalService", "LocalSystem" and...
1
6552
by: brian.oneil2 | last post by:
Is there a way to install this onto a network file share and allow a team to access it? I would say share a CD from a networked CD drive, but there are multiple CD's that would have to be inserted....
11
3045
by: Andre | last post by:
Hi, I have ASP.NET application running on standalone (not part of the domain) Windows 2003. I use forms authentication for my application. The problem I have is that I need to create and read...
4
8765
by: Alex | last post by:
Hi All I'm writing scripts in VBS fore years. But now I've to write a tool in Visual Basic .Net which has to connet to a Windows domain. I know how to do this in VBS but I don't find a way in...
0
2320
by: Dennis | last post by:
I have tried to use the IWshRuntimeLibrary and ManagementObjectSearcher("SELECT * FROM Win32_LogicalDisk") to get all Logical Drives, Mapped Network Drives, Shared Folders and Shared Drives with...
3
5196
by: Miriam | last post by:
Hello, I created a Windows Service in VB.NET, which is to purge files periodically in the local system and also in the shared network drive. Here is my problem: 1. If I set the “Account”...
1
1619
by: mpltkvx | last post by:
Hello, This is a question regarding MS-Access programming. 1. Network environment: I got a room with 50 people answering the phone and logging the topics of the incoming calls. Each has a PC,...
5
1789
by: ordy62 | last post by:
I split a database to a FE and BE but the issue is the network shares. I have several groups that need to view this database but the network paths to database are different for example. ...
0
7278
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7328
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6991
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7458
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5013
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1512
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
380
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.