Re: just to clarify ...
From: Randy Birch (rgb_removethis_at_mvps.org)
Date: 01/21/05
- Next message: NickHK: "Re: switching word documents in VB6"
- Previous message: Randy Birch: "Re: How to tell if Desktop visible"
- In reply to: ZP: "just to clarify ..."
- Next in thread: MikeD: "Re: just to clarify ..."
- Messages sorted by: [ date ] [ thread ]
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 : > : > : :
- Next message: NickHK: "Re: switching word documents in VB6"
- Previous message: Randy Birch: "Re: How to tell if Desktop visible"
- In reply to: ZP: "just to clarify ..."
- Next in thread: MikeD: "Re: just to clarify ..."
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|