Re: just to clarify ...

From: Randy Birch (rgb_removethis_at_mvps.org)
Date: 01/21/05


Date: Thu, 20 Jan 2005 22:08:11 -0500

Generally it's correct, but if for some reason the call fails, Ret will be 0
and the Left$ call will throw an error. I prefer to either test implicitly
for the presence of a chr$(0) before assuming I can chop it off (see
http://vbnet.mvps.org/code/system/windirs.htm), or alternatively use the api
version of trimnull which will return either the proper string or an empty
string if the call failed. Regardless, GetSystemDirectory will work on all
Windows versions to date.

-- 
Randy Birch
MS MVP Visual Basic
http://vbnet.mvps.org/
"ZP" <zeebee@SPAMOUTop.pl> wrote in message 
news:csoegd$5h9$1@nemesis.news.tpi.pl...
: Using an advice from Randy Birch and J. French (thank You gentlemen) I 
went
: for API.
: For example purposes I used small Access dbase located in System32 folder.
: ----------------------------------------
: Questions:
: --------------
: 1. Did I do it correctly? (well, it works)
:
: 2. Will it work on any (all) Windows based systems?
:    (I mean on 95, 98, 98SE, NT 4.0, CE, ME, 2000, XP, 2003S)
:
: 3. Are there any dangers and weak spots unvisible to newbe, which may make
: app to         terminate?
:
: 4. Should I make some modifications?
:
:
: ------------------------
: code (partial):
: ------------------------
: 'API
: Private Declare Function GetSystemDirectory Lib "kernel32" Alias
: "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As
: Long
: ------------
: Private Sub Form_Load()
:
:    Dim sSave As String, Ret As Long    'API
:
:
:    Command3.Visible = True                     'shows if Command3 visible
:    '---API-------
:        sSave = Space(255)
:                    'Get the system directory
:        Ret = GetSystemDirectory(sSave, 255)
:                    'Remove all unnecessary chr$(0)'s
:        sSave = Left$(sSave, Ret)
:        DBName = sSave + "\test.mdb"
:
:    '---API-------
: -------------------------
: end code (partial)
:
:
:
:
:
: U?ytkownik "ZP" <zeebee@SPAMOUTop.pl> napisa3 w wiadomo6ci
: news:csnacm$i4k$1@nemesis.news.tpi.pl...
: > I have this question.
: > Please help me understand.
: > -----------------------------------
: > Let's say, during installation, I want to create a folder, say 
"MyFolder"
: in
: > one of those system folders:
: > --- Windows , or
: > --- System32 , or
: > --- Application Data Folder, or
: > --- Common Files Folder,
: > and locate there some file, my application would use less or more
: > frequently.
: >
: > Well, sometimes Windows are not installed on drive C:\ and names of
: folders
: > (dirs) may vary, so I cannot write down exact path, say:
: >
: > DBName = "c:\windows\system\MyFolder\anyfile.ext"
: >
: > Is there a way to make this path relative (do I use right word in
: English?),
: > or
: >
: > Is there a way to make this paths "universal", so no matter what type of
: > Windows or drive names (letters) my app encounters, it won't turn belly 
up
: > and die.
: >
: > say:
: > DBName = "\WindowsFolder\MyFolder\anyfile.ext"    , or
: > DBName = "\AppDataFolder\MyFolder\anyfile.ext"    , or
: > DBName = "\CommonFilesFolder\MyFolder\anyfile.ext"     etc ...
: >
: > ------------------
: > thnx
: >
: >
:
: 


Relevant Pages

  • Re: How do I delete a folder through code?
    ... SHFILEOPSTRUCTW info =; ... SHFileOperation function the string field is designed to handle a ... This folder contains a long chain of subfolders that exceeds Window's ... I originally get the name of the folder from a Windows ...
    (microsoft.public.vc.mfc)
  • Re: Event Log Files
    ... On the Windows menu, click HKEY_LOCAL_ MACHINE on Local Machine. ... Type the new drive and path in the String box, ... any help in this regard will be greatly appreciated. ...
    (microsoft.public.win2000.security)
  • Re: UTF-8 problems with windows
    ... private String test() { ... String ret = null; ... On Windows xp I get neither firefox nor IE to work correctly. ... UTF-8 encoding to ISO-8859-1, it displays things correctly. ...
    (comp.lang.java.programmer)
  • Re: Other version information
    ... header to locate the resource table. ... Windows PE files ... marked by a literal string. ... files in a folder, ...
    (microsoft.public.scripting.vbscript)
  • UTF-8 problems with windows
    ... private String test() { ... String ret = null; ... On Windows xp I get neither firefox nor IE to work correctly. ... UTF-8 encoding to ISO-8859-1, it displays things correctly. ...
    (comp.lang.java.programmer)

Quantcast