473,655 Members | 3,105 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Generic Access to Special Folders

Hi,

I'm developing on WinXP and deploying on W2K so the path
to System32 directory is different on each system. I'm
trying to import DLLs from the Win32 API, but I have to
change the path and recompile before punching things up
to the server.

private const string SYSTEM32_PATH = @"C:\Winnt\Syst em32
\"; // Or locally @"C:\Windows\Sy stem32\";
[DllImport(SYSTE M32_PATH + "Kernel32.d ll")]
public static extern int GetLastError();

Is there a standard format for getting access to these
directories?? I thought it was something like %System%
but I think I've tried every combination of '/', '\'
and '%' to no avail. The help sytem has, as usual, not
lived upto it's name...!!

Thanks in advance
Paul
Jul 21 '05 #1
4 2849
>I'm developing on WinXP and deploying on W2K so the path
to System32 directory is different on each system.


Why not just use the Environment.Sys temDirectory property?

Or if you need access to other "special" system directories, use the
Environment.Get FolderPath() method.

Marc

=============== =============== =============== =============== ====
Marc Scheuner May The Source Be With You!
Bern, Switzerland m.scheuner(at)i nova.ch
Jul 21 '05 #2
Thanks but I'd tried that...
I hadn't really expected it to work as the DllImport
requires a string constant at compile time and those
calls to Environment are evaluated at runtime..
And alas it didn't :-(

Hence I've been hunting for some sort of generic OS
recognised moniker for these particular directories.

It must exist, surely we don't have to recompile
components for clients who installed Windows on D:
instead of C:. Or for when MS, in their wisdom, decide to
change from "WINNT" to "Windows" and no doubt
to "Windows.Ne t" some time soon!
-----Original Message-----
I'm developing on WinXP and deploying on W2K so the pathto System32 directory is different on each system.
Why not just use the Environment.Sys temDirectory

property?
Or if you need access to other "special" system directories, use theEnvironment.Ge tFolderPath() method.

Marc

============== =============== =============== ============= =======Marc Scheuner May The Source Be With You!Bern, Switzerland m.scheuner(at) inova.ch.

Jul 21 '05 #3
"Paul Lyons" <pa**@nospam.th e-lyons.com> wrote in news:078001c37b 74
$8************* ***@phx.gbl:

private const string SYSTEM32_PATH = @"C:\Winnt\Syst em32
\"; // Or locally @"C:\Windows\Sy stem32\";
[DllImport(SYSTE M32_PATH + "Kernel32.d ll")]
public static extern int GetLastError();


When using dll's in the Windows system folders, I don't think it's
necessary to specify the full path to the .dll. I think you only need the
full path if the dll is not in a Windows system folder.

Can someone confirm or deny this?

Chris
Jul 21 '05 #4
That does seems to work! - Thanks

It's obvious really, 'cos the System32 directory is going
to be in the OS PATH list...
That's the trouble with amending someone elses code - I
forget how to think for myself!! They had put the full
path in, so I figured it was needed, and never looked
further than that :(
-----Original Message-----
"Paul Lyons" <pa**@nospam.th e-lyons.com> wrote in news:078001c37b 74$8************ ****@phx.gbl:

private const string SYSTEM32_PATH = @"C:\Winnt\Syst em32 \"; // Or locally @"C:\Windows\Sy stem32\";
[DllImport(SYSTE M32_PATH + "Kernel32.d ll")]
public static extern int GetLastError();

When using dll's in the Windows system folders, I don't

think it'snecessary to specify the full path to the .dll. I think you only need thefull path if the dll is not in a Windows system folder.

Can someone confirm or deny this?

Chris
.

Jul 21 '05 #5

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

Similar topics

6
4739
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much appreciated. Thanks in advance
1
2415
by: Jim Haynes | last post by:
Does anyone know of a simple way to retrieve WITH CODE the path to special folders such as the 'My Documents' or 'Application Data' folders. I can do it with api calls using sffolder, etc but I would like to avoid those in the future and thought that would be possible in vb.net 2003. I can use the Folder Browser dialog tool in Vb.net 2003 but then it seems that it must be displayed to the User!. I want to retrieve and use the special...
12
1811
by: Quemasda | last post by:
Hi, The application I'm working on should set the Special Folders (Favorites, My Documents, ...) but I can't find the way to do it. So far, I've been able to get the path of those Special Folders but not set them. Does anybody know how? Thanks in advance, Que_Mas_Da.
4
237
by: Paul Lyons | last post by:
Hi, I'm developing on WinXP and deploying on W2K so the path to System32 directory is different on each system. I'm trying to import DLLs from the Win32 API, but I have to change the path and recompile before punching things up to the server. private const string SYSTEM32_PATH = @"C:\Winnt\System32 \"; // Or locally @"C:\Windows\System32\";
12
8009
by: wheels619 | last post by:
How can I get access for another user's special folder locations? A configuration file is stored in the users' appData folder and the program altering it will be ran under the admin.
0
1484
by: staffonline | last post by:
Hi Friends, I recently can not access our share folder on a file server. the share folder have special permissions (only some domain groups allowed, but i was a member of that group). but i could access for some public folders ( everyone can access) the strange thing is i try to use another workstation, there is no problem for me to access that folders.
2
1682
by: staffonline | last post by:
Hi Friends, I recently can not access some share folder on a file server. the share folders have special permissions (only some domain groups allowed, i was a member of that group). but i could access for some public folders (on the same server which everyone could access) the strange thing is i try to login to another workstation, there is no
5
10187
by: Nosferatum | last post by:
I am in need of a solution on how to solve this problem: I need to limit access to six different folders. My users are validated in a system which check their prescence with a couple of variables in a db and then forwards them if they exist. Based upoen their status they are redirected to one of six folders. Users belonging to group A shall get access to folder A, but not B, C etc. It must be possible to limit access in this order by...
10
4562
by: Arno R | last post by:
Hi all, So I bought a new laptop 10 days ago to test my apps with Vista. (home premium) Apparently Office 2007 is pre-installed. (a time limited but complete test version, no SP1) So I take the opportunity to test some new features of Access2007 before actually 'stepping over'. First thing that troubles me of course is 'the ribbon', but my question now is about speed. I opened one of my Access 2000-apps in Access 2007. Speed and...
0
8380
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8296
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8816
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8710
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
5627
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4299
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2721
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 we have to send another system
2
1928
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1598
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.