473,325 Members | 2,308 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

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\System32
\"; // Or locally @"C:\Windows\System32\";
[DllImport(SYSTEM32_PATH + "Kernel32.dll")]
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 2829
>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.SystemDirectory property?

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

Marc

================================================== ==============
Marc Scheuner May The Source Be With You!
Bern, Switzerland m.scheuner(at)inova.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.Net" 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.SystemDirectory

property?
Or if you need access to other "special" system directories, use theEnvironment.GetFolderPath() 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.the-lyons.com> wrote in news:078001c37b74
$8****************@phx.gbl:

private const string SYSTEM32_PATH = @"C:\Winnt\System32
\"; // Or locally @"C:\Windows\System32\";
[DllImport(SYSTEM32_PATH + "Kernel32.dll")]
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.the-lyons.com> wrote in news:078001c37b74$8****************@phx.gbl:

private const string SYSTEM32_PATH = @"C:\Winnt\System32 \"; // Or locally @"C:\Windows\System32\";
[DllImport(SYSTEM32_PATH + "Kernel32.dll")]
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
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...
1
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...
12
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...
4
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...
12
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
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...
2
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...
5
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...
10
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.