Wrox Programmer Forums
|
Pro VB 6 For advanced Visual Basic coders working in version 6 (not .NET). Beginning-level questions will be redirected to other forums, including Beginning VB 6.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 14th, 2007, 04:29 AM
Authorized User
 
Join Date: Jun 2007
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to ivanlaw Send a message via Yahoo to ivanlaw
Default Windows registry

May I know that if I did not set location of the .ini file, then by default it will be store at where?
Waiting for your advice...

Thank you.
 
Old November 14th, 2007, 06:07 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

I don’t think so. Why not specify where it is?
 
Old November 15th, 2007, 12:03 AM
Authorized User
 
Join Date: Jun 2007
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to ivanlaw Send a message via Yahoo to ivanlaw
Default

Hi there,
Actually I am a newbie to use this .ini file and windows registry, so can you teach me how to specify a location for it?
Because the book which I read it just teach me how to create it without specify a location for it.Example of the coding is below:
SaveSetting "my_app", "User", "Name", "Ken"
That is all.
Please teach me,I waiting for your advice.

Thank you.
Quote:
quote:Originally posted by BrianWren
 I don’t think so.  Why not specify where it is?
 
Old November 15th, 2007, 02:25 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

This is the declaration to read an INI file:
Code:
Declare Function GetPrivateProfileString _
        Lib "kernel32" _
        Alias "GetPrivateProfileStringA" (ByVal lpSctNm As String, _
                                          ByVal lpKeyNm As String, _
                                          ByVal lpDflt As String, _
                                          ByVal lpRtrnBfr As String, _
                                          ByVal nSize As Long, _
                                          ByVal lpfNam As String _
                                         ) As Long
                                         Then you use this to get the value for a specific entry (key) within a specific section:
Code:
    Const Size = nnn
Code:
    Dim Bfr  As String
    Dim Rtrn As Long
    Dim s    As String
    Dim i    As Integer

    Bfr = Space$(Size)

    Rtrn = GetPrivateProfileString(Section, key, DefaultValue, Bfr, Size, IniFile)

    s = Left$(Bfr, InStr(Bfr, vbNullChar) - 1)

    ' The fol. 2 lines permit using semicolons to put 
    ' comments on lines in the ini.
    i = InStr(s, ";")
    If i > 0 Then s = Trim$(Left$(s, i - 1))
    Section would be the string that marks a section in the INI. key would be the specific entry. DefaultValue is what will be returned if the key is not found. Bfr is the string buffer that the result will be put into. Size tells the API function the size of Bfr. IniFile is a string holding the fully-qualified path and filename for the INI you want to get the value from.
 
Old November 16th, 2007, 03:59 AM
Authorized User
 
Join Date: Jun 2007
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to ivanlaw Send a message via Yahoo to ivanlaw
Default

Hi Pro,
May I know what codes I learn from the book?
Because after I see your coding that you post to me, I can say that is completely different.Is it I learn Windows registry?
The Coding I learn for read is below:
GetSetting("my_app","User","Name")

Could you tell the answer,please?
Waiting for your advice.

Thank you.
 
Old November 16th, 2007, 05:41 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

What I poted has nothing whatsoever to do with the Registry.

You say:
Quote:
quote:Actually I am a newbie to use this .ini file and windows registry, so can you teach me how to specify a location for it?
Because the book which I read it just teach me how to create it without specify a location for it.
But this is unclear. When you say “...location for it,” you have just used 2 nouns. That which “it” refers to could be either the Registry or an ini file. But the location of the Registry is a meaningless concept, and you have not specified what ini file you might be looking for. You can put an ini file anywhere you like... there fore the following
Quote:
quote:May I know that if I did not set location of the .ini file, then by default it will be store at where?
is unanswerable. It is like saying "If I don't specify the location of a .txt, where would it be by default?"

What does, “May I know what codes I learn from the book?” mean? It is as if you are asking me, "Please tell me what I know."

You say, "Could you tell the answer,please?" The answer to what?

GetSetting does not have anything whatsoever to do with ini files. It gets a value out of the Registry, which is not an ini file.

Could you please read your posts before posting them to see if they say what you mean?

Remove politeness items like "please" "may I" "waiting for . . ." "thank you" salutations ("Hi", etc.), don't explain that you are a newbie, "Please teach me", and so on.

I already know that you want to know the answer to what you are asking just because you asked. Being polite like this makes it harder for you to assemble your post, and makes them harder to read. (Don't apologize.)

Just post exactly what you want to know, or what you are trynig to do ("How do I read a value from the Registry?" "How do I get a value out of a .INI file?", etc.). that will be easier for everyone.

I do not have the book you have, whattever it is. The people answering here do not work for WROX. We are just people around the world who use this site, and contribute when we can.
 
Old November 17th, 2007, 03:32 AM
Authorized User
 
Join Date: Jun 2007
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to ivanlaw Send a message via Yahoo to ivanlaw
Default

OK...I will ask the question as direct as I can.
1.)What did you means"the location of the Registry is a meaningless concept"?
2.)So how I set location for the Windows registry after you see the coding that I already posted?

Thank you.

 
Old November 19th, 2007, 12:41 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

The registry is addressed by using registry-addressing functions. There is no concept involved that involves know where it is. In fact, it is in memory plus being located in the file system. You do not specify its location when using it. It is like praying to God: You don’t need to concern yourself with where He is. You speak to Him, He hears. You read the registry, the data arrive.

What is it that you are trying to do? Perhaps a broader view would make it easier to help you. Something like, “I need to store 2 pieces of data for a given user so that it will be there for him the next time he starts the machine and logs in. How can I use the Registry for this? Is there a better way? I am using VB6.”





Similar Threads
Thread Thread Starter Forum Replies Last Post
Windows Registry Indraja VB.NET 0 June 6th, 2007 06:55 AM
Windows Registry Editing via Java Sandz J2EE 0 February 28th, 2005 10:05 AM
Registry snowy0 VB.NET 2002/2003 Basics 1 September 8th, 2004 10:40 AM
Windows Registry kumar_rajeshk Pro VB 6 6 April 29th, 2004 01:08 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.