Announcement

Collapse
No announcement yet.

SHELL, synchronous or not?

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

  • SHELL, synchronous or not?

    This is what I find in PBDLL60 Help:
    "The Shell statement runs other programs synchronously. That means that execution of your code is
    suspended until the shelled program finishes."

    And this is what really happens:
    If my application does not find a correct Language Identifier, it shells to the Control Panel
    application "Regional Settings", in order to let the user change these 'wrong' setting. Before the
    OK-button of that dialog has been clicked, my application is going on already.
    So, either the information in PB's help file is not correct or Control Panel is an exception on the
    rule. Anyhow, is there a way to work around this problem? I myself was thinking of changing the
    settings on the fly, but as far as I understand Microsoft help (win32.hlp) this is not possible.

    And, talking about this issue, what shall I use to detect the identifier:
    %LOCALE_SYSTEM_DEFAULT or %LOCAL_USER_DEFAULT?


    ------------------
    mailto:[email protected][email protected]</A>
    www.basicguru.com/zijlema/

    Egbert Zijlema, journalist and programmer (zijlema at basicguru dot eu)
    http://zijlema.basicguru.eu
    *** Opinions expressed here are not necessarily untrue ***

  • #2
    How are you executing the "Regional Settings" CPL?

    Are you shelling to this:

    "control.exe c:\winnt\System32\main.cpl" because even if you
    shell synchronously with that previous command it will return
    immediatly because control.exe exits immediatly.

    Hope that helps.

    ------------------
    -Greg
    -Greg
    [email protected]
    MCP,MCSA,MCSE,MCSD

    Comment


    • #3
      Gregery,

      This is the code involved (slightly modified for the test)
      Code:
      #COMPILE EXE
      #INCLUDE "WIN32API.INC"
      
      FUNCTION PBMain() AS LONG
        LOCAL szLangID AS ASCIIZ * 64
        GetLocaleInfo %LOCALE_SYSTEM_DEFAULT, %LOCALE_ILANGUAGE, szLangID, SIZEOF(szLangID)
        IF szLangID <> "0413" THEN             ' if not Dutch(Standard)
          GetLocaleInfo %LOCALE_SYSTEM_DEFAULT, %LOCALE_SLANGUAGE, szLangID, SIZEOF(szLangID)
          answer& = MSGBOX("The language settings are not correct: " + UCASE$(szLangID) + _
                           REPEAT$(2, $CRLF) + _
                           "Click OK to modify, Cancel to stop and call your" + $CRLF + _
                           "system administrator for help.", _
                           %MB_OKCANCEL OR %MB_ICONQUESTION, "Incorrect language")
          IF answer& = %IDCANCEL THEN
            EXIT FUNCTION                    ' quit
          ELSE
            SHELL "control intl.cpl"         ' run Regional settings
          END IF
        END IF
        MSGBOX "You have started Control Panel, but nevertheless this message shows up", 64, _
               "Application continues"
      END FUNCTION
      ------------------
      mailto:[email protected][email protected]</A>
      www.basicguru.com/zijlema/

      Egbert Zijlema, journalist and programmer (zijlema at basicguru dot eu)
      http://zijlema.basicguru.eu
      *** Opinions expressed here are not necessarily untrue ***

      Comment


      • #4
        Egbert --

        Greg nailed it. SHELL is working properly, the problems is that the CONTROL program is not synchronous. SHELL is launching CONTROL and waiting for it to return. CONTROL is launching the control panel applet and then returning immediately, before the applet exits. So when CONTROL exits SHELL allows your program to continue running.

        -- Eric


        ------------------
        Perfect Sync: Perfect Sync Development Tools
        Email: mailto:[email protected][email protected]</A>

        [This message has been edited by Eric Pearson (edited February 22, 2001).]
        "Not my circus, not my monkeys."

        Comment


        • #5
          Control.exe is a 16 bit app for backward... reasons.
          Iow's don't use it..

          ------------------
          hellobasic

          Comment


          • #6
            Classic way for Win95+ is
            Shell "rundll32.exe shell32.dll,Control_RunDLL intl.cpl,Regional Settings"

            ------------------
            E-MAIL: [email protected]

            Comment


            • #7
              Thank you, Semen!
              Did'nt know this. Tested it and let the CP applet alone during a cup of coffee. It still was there.
              In other words: problem solved.


              ------------------
              mailto:[email protected][email protected]</A>
              www.basicguru.com/zijlema/

              Egbert Zijlema, journalist and programmer (zijlema at basicguru dot eu)
              http://zijlema.basicguru.eu
              *** Opinions expressed here are not necessarily untrue ***

              Comment

              Working...
              X