Announcement

Collapse
No announcement yet.

Writing Console FontSize in Registry

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Writing Console FontSize in Registry

    I've written a little wrapper program to fire up and set the console font size
    for my PBCC application. For some reason, I cannot seem to write rData successfully to the registry. What am I doing wrong here? It must be simple and I just can't see it.

    My installer program performs the task perfectly when give it
    0x000c0005 as a value to write, so I'm puzzled. I'm sure I'll be
    embarrassed when someone illumines the problem.

    -----------------------

    lpKey = %HKEY_CURRENT_USER
    cMainKey = "Console"
    Key = "FontSize"

    FUNCTION SetConsoleRegValue(lpKey AS LONG,BYVAL cMainKey AS STRING, BYVAL Key AS STRING) AS LONG

    ON ERROR RESUME NEXT
    LOCAL hKey AS LONG
    LOCAL Result AS LONG
    Local rData As String
    IF Key = "*" THEN Key = CHR$(0,0)
    IF RegCreateKeyEx(lpKey, cMainKey + CHR$(0),0, "", %REG_OPTION_NON_VOLATILE, _
    %KEY_ALL_ACCESS, BYVAL %NULL, hKey, Result) <> %ERROR_SUCCESS THEN
    FUNCTION = 0
    EXIT FUNCTION
    END IF

    rData = "0x000c0005" + chr$(0)

    RegSetValueEx hKey, Key+CHR$(0), 0, %REG_DWORD, ByVal StrPtr(rData), 11

    RegCloseKey hKey
    FUNCTION = 0
    END Function
    Last edited by Craig Slane; 14 Jan 2009, 01:56 PM.
    Craig J. Slane
    Nostalga Sim Baseball

  • #2
    >REG_DWORD, ByVal StrPtr(rData), 11

    When you write a REG_DWORD, you should supply the address of a DWORD, not the address of a string containing a hex representation of that DWORD.
    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      Thank you, Micahel ....

      So (bear with me here), to my mind that would mean I need to locate the 32 bit address of rData like this:

      Dim x as String
      x = STRPTR(rData)

      ... and then use ByVal x as the parameter?

      Is that correct? I tried it and what shows in the registry is this message:

      (Invalid DWORD (32 Bit) value)

      I must not yet understand.
      Last edited by Craig Slane; 14 Jan 2009, 03:05 PM.
      Craig J. Slane
      Nostalga Sim Baseball

      Comment


      • #4
        You want something along the lines of...

        DIM dwValue AS DWORD

        dwValue = &H000C0005

        Then use BYVAL VARPTR(dwValue) instead of BYVAL STRPTR(whatever).

        -- Eric

        P.S. Or you could simply use the CWC wrapper program that is provided with Console Tools -- of which you are a licensee -- to set the console font size.
        Last edited by Eric Pearson; 14 Jan 2009, 03:54 PM.
        "Not my circus, not my monkeys."

        Comment


        • #5
          The cat's meow, Eric. Success. Not at first, but after I added a small SLEEP interval behind it, all was well. Thanks for the great help here.
          Craig J. Slane
          Nostalga Sim Baseball

          Comment


          • #6
            You ARE sure you want to make a permanent change to the using system, right?

            If so, please remove this feature from any of your software I might license before you ship, or at least make it an option!
            Michael Mattias
            Tal Systems (retired)
            Port Washington WI USA
            [email protected]
            http://www.talsystems.com

            Comment

            Working...
            X