Results 1 to 8 of 8

Thread: INI_GetKey problem when ini file name is CLOCK.INI

  1. #1
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    51
    Posts
    8,334
    Blog Entries
    2
    Rep Power
    10

    INI_GetKey problem when ini file name is CLOCK.INI

    Hi all,

    I've spent almost an hour getting crazy why INI_GetKey not working anymore.
    I've got a message from Bevan stating that he created a CLOCK.INI file in the same directory of thinBasic script he is doing and he was not able to read any of the keys inside that ini file while he was perfectly able to use INI_GetSectionsList or INI_GetSectionKeyList function. I made some tests and Bevan was right. So a simple
    [code=thinbasic]
    INI_GetKey(app_sourcepath & "Clock.ini", "Setup", "Mininumpregametime", "")
    [/code]
    was not returning anything.

    The difference between INI_GetSectionsList or INI_GetSectionKeyList function and INI_GetKey is that INI_GetSectionsList and INI_GetSectionKeyList are home made functions while INI_GetKey is a wrapper of GetPrivateProfileString API function.

    To get it short, the problem seems ini file name. If ini file name is "CLOCK.INI" GetPrivateProfileString seems to try to take data from somewhere else file or place while using something like the following where ini file name is NOT CLOCK.INI:
    [code=thinbasic]
    INI_GetKey(app_sourcepath & "_Clock.ini", "Setup", "Mininumpregametime", "")
    [/code]
    all is working as expected. Note that here we are specifing full ini file path and not just the file name so no way to confuse with other files around.

    Does anyone have an idea why? I was not able to find info on Microsoft docs. At this point I suppose CLOCK.INI is a reserved name.

    Thanks
    Eros

    www.thinbasic.com | www.thinbasic.com/community/ | psch.thinbasic.com
    Win10Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

  2. #2
    thinBasic MVPs Michael Hartlef's Avatar
    Join Date
    Sep 2006
    Location
    Leverkusen, Germany
    Age
    52
    Posts
    3,283
    Blog Entries
    2
    Rep Power
    340

    Re: INI_GetKey problem when ini file name is CLOCK.INI

    Maybe \C as part of the file path is a control character and is interpreted like that?
    Running Windows 7 Home, 64 bit, 8 GB ram, Athlon II X2 255, ATI Radeon HD 4200.

  3. #3
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    51
    Posts
    8,334
    Blog Entries
    2
    Rep Power
    10

    Re: INI_GetKey problem when ini file name is CLOCK.INI

    Nice idea but it is not because CCLOCK.INI works fine

    Anyhow thanks
    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | psch.thinbasic.com
    Win10Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

  4. #4
    thinBasic MVPs
    Join Date
    May 2007
    Location
    UK
    Posts
    1,427
    Blog Entries
    1
    Rep Power
    154

    Re: INI_GetKey problem when ini file name is CLOCK.INI

    Seems to a hangover from win3.1. Its the filename.

    http://www.microsoft.com/technet/arc....mspx?mfr=true

    How Does Mapping Work?
    NT implements mapping by trapping the private profile API routines I mentioned in Chapter 1. Windows applications and components ordinarily use these calls to get and set data stored in INI files, but when there's a mapping entry, the NT kernel first checks for the presence of a mapping key. If one exists, and if it points to a key that contains data, that data is returned to the caller. If there's no mapping key, or if it points to an empty or non-existent Registry key, NT will go ahead and try to read the data from the INI file. The caller need never be aware that the data didn't come from the requested file.

    Mapping only occurs when there's a mapping key in place. These keys are stored beneath the HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\IniFileMapping subkey. If you look there, you'll notice a number of subkeys with names like Clock.INI, Win.INI, and SYSTEM.INI. These keys tie sections of the old Win 3.1-style INI files to keys in the Registry so that old Windows 3.1 components like the Clock and the original media controller interface (MCI) will continue to find their settings.
    Home Desktop : Windows 7 - Intel Pentium (D) - 3.0 Ghz - 2GB - Geforce 6800GS
    Home Laptop : WinXP Pro SP3 - Intel Centrino Duo - 1.73 Ghz - 2 GB - Intel GMA 950
    Home Laptop : Windows 10 - Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz, 2401 Mhz, 2 Core(s), 4 Logical Processor(s) - 4 GB - Intel HD 4400
    Work Desktop : Windows 10 - Intel I7 - 4 Ghz - 8GB - Quadro Fx 370

  5. #5
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    6,827
    Blog Entries
    3
    Rep Power
    696

    Re: INI_GetKey problem when ini file name is CLOCK.INI

    Good find Abraxas !

    This was really tricky problem, good solved so fast

    Bye,
    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 7 64bit - Intel Core 2 Duo T6600 @ 2.2GHz - 4 GB RAM - NVIDIA GeForce G210M 512MB
    Windows 8 64bit - Intel Core i5-3350P @ 3.1GHz - 8 GB RAM - NVIDIA GeForce GT640 3GB

  6. #6
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    51
    Posts
    8,334
    Blog Entries
    2
    Rep Power
    10

    Re: INI_GetKey problem when ini file name is CLOCK.INI

    Thanks a lot Abraxas.
    That's what a community is: help each other and exchange ideas and knowledge to have a common bigger shared knowledge.
    www.thinbasic.com | www.thinbasic.com/community/ | psch.thinbasic.com
    Win10Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

  7. #7

    Re: INI_GetKey problem when ini file name is CLOCK.INI

    ;D this is the reason that I not removed the registry storage from ThinAIR!

    Roberto
    http://www.thinbasic.com

  8. #8
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    6,827
    Blog Entries
    3
    Rep Power
    696

    Re: INI_GetKey problem when ini file name is CLOCK.INI

    ;D

    Vampires ? Werewolfes ? Zombies ?

    No. The only thing I am really afraid of are Windows Registry .
    But good thinAIR works with them ok


    Bye,
    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 7 64bit - Intel Core 2 Duo T6600 @ 2.2GHz - 4 GB RAM - NVIDIA GeForce G210M 512MB
    Windows 8 64bit - Intel Core i5-3350P @ 3.1GHz - 8 GB RAM - NVIDIA GeForce GT640 3GB

Similar Threads

  1. The Clock
    By danbaron in forum Shout Box Area
    Replies: 2
    Last Post: 20-09-2010, 11:02

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •