Problem using GetPrivateProfile to set current path 
Author Message
 Problem using GetPrivateProfile to set current path

I'm calling GetPrivateProfileString to read my INI file from a
separate module.  I have to initialize the return string 'srcdir' with
the command srcdir = String$(iLength, 0) where iLength = 255.
The returned string, when I examine it, has a bunch of 'blank'
characters at the end; e.g., C:\MYDIREC\_ _ _ _ _ _ _ ...
except they're not underscores, they're solid boxes.  First, I'd like
to figure out how to get rid of those.  The Trim function didn't work,
and adding double-quotes " around the data in my INI file didn't
work either.  My problem comes in when I try make the assignment:
  frmMINE!filDemog.Path = srcdir
to set the current path for my directory window.  When I run this,
I get the 'out of stack space error' #28, and always on that line.
I think I may not be declaring something correctly for the
GetPrivateProfile routine, or maybe I'm having trouble using it in the
module.  It worked fine when the GPPS routine was under the same form,
and I didn't have to use the  frmMINE! part of the assignment.
  I just started moving things to a module, because I am adding a
second form to my program, and many of the variables will be used in
both forms.
  THANKS FOR HELPING!

Bill



Sat, 05 Dec 1998 03:00:00 GMT  
 Problem using GetPrivateProfile to set current path


Quote:
>I'm calling GetPrivateProfileString to read my INI file from a
>separate module.  I have to initialize the return string 'srcdir' with
>the command srcdir = String$(iLength, 0) where iLength = 255.
>The returned string, when I examine it, has a bunch of 'blank'
>characters at the end; e.g., C:\MYDIREC\_ _ _ _ _ _ _ ...

The GetPrivateProfileString function returns the number of data characters
in the return string. This means that you should do:

buffer = Left$(buffer, retval)

after you've called GetPrivateProfileString. Anyway, you can get
ftp://ftp.sn.no/user/balchen/vb/source/profiles.zip for easier access to
Get-/WritePrivateProfileString

--
VB Info: http://www.sn.no/~balchen/vb/visual.htm
FAQ: http://www.sn.no/~balchen/vb/faq.htm
Knowledge Base: http://www.sn.no/~balchen/vb/kb.htm



Sat, 05 Dec 1998 03:00:00 GMT  
 Problem using GetPrivateProfile to set current path

Quote:

> I'm calling GetPrivateProfileString to read my INI file from a
> separate module.  I have to initialize the return string 'srcdir' with
> the command srcdir = String$(iLength, 0) where iLength = 255.
> The returned string, when I examine it, has a bunch of 'blank'
> characters at the end; e.g., C:\MYDIREC\_ _ _ _ _ _ _ ...

[chomp]

The return value of GetProfileString and GetPrivateProfileString
is the number of valid characters put into the buffer. Try this:

Dim r As Integer, Buf As String
Buf = String$(255, 0)
r = GetPrivateProfileString("foo", "bar", "default", Buf, Len(Buf), INIFile)
Buf = Left$(Buf, r)

--

WARNING: I cannot be held responsible for the above        They're   coming  to
because  my cats have  apparently  learned to type.        take me away, ha ha!



Sat, 05 Dec 1998 03:00:00 GMT  
 Problem using GetPrivateProfile to set current path

Dim Result As Integer, srcDir As String

srcDir = Space$(257)
Result = GetPrivateProfileString("Catalogs", "LastUsed", App.Path, srcDir, Len(srcDir), "c:\progs\anyfile.ini")
srcDir = Left$(srcDir, Result)

This is how You should cut the trailing zeros (or in my case, spaces).
App.Path is added in case the key LastUsed is not present, ie App.Path becomes default value.

See Help file for more information...

Peter Larsson



Sat, 05 Dec 1998 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Setting the path to the path of the current application

2. Setting path to location of current mdb file

3. How do I set path current from dir1 and drive1 objects

4. Set/get current row using table object

5. Finding/Seeking/setting the current record when using a data control

6. Setting Save As path in Powerpoint using VBA

7. Set the DatabaseName Property using no path

8. Set Database Name property using no path

9. Setting default export path using Crystal32.ocx

10. Set Database name using no path

11. Listview problem - Setting the current line to display

12. Set database location path problem (OCX) (C++)

 

 
Powered by phpBB® Forum Software