Announcement

Collapse
No announcement yet.

SHShutDownDialog

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

  • SHShutDownDialog

    Hi everybody,

    the following function pops up the Shut Down Dialog.

    does anyone knows why this function:
    ---
    DECLARE FUNCTION SHShutDownDialog LIB "Shell32.dll" ALIAS "#60" (BYVAL lType AS LONG) AS LONG
    ---
    is not working in PB/DLL 6.0
    In VB it works pretty well.

    I'm compiling on a win2000 machine has that anything todo with it?

    Oh btw. don't look around the api because this function is not public.

    Best Regards.
    Tom



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

  • #2
    Tom --

    SHShutDownDialog is not an "exported" function in SHELL32.DLL and it therefore can't be linked to your program in that way. Blame Microsoft You would need to use the LoadLibrary and GetProcAddress APIs, and then use CALL DWORD to call the function. Search the BBS for LoadLibrary and you should find several examples. The only difference is that instead of passing a pointer to the function name to GetProcAddress, you would pass the numeric value 60.

    I'll skip the usual warnings about using undocumented API functions like SHShutDownDialog...

    -- Eric


    ------------------
    Perfect Sync Development Tools
    Perfect Sync Web Site
    Contact Us: mailto:[email protected][email protected]</A>

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

    Comment


    • #3
      Agreed that this is not a safe technique. The main problem, though, is that
      the ALIAS "#60" is attempting to link to the routine by number rather than
      by name. This syntax is not supported by PowerBASIC.


      ------------------
      Tom Hanlin
      PowerBASIC Staff

      Comment


      • #4
        ALIAS "#60" is attempting to link to the routine by number rather than
        by name. This syntax is not supported by PowerBASIC.
        Tom, any chance it will be possible to statically link to exported functions by ordinal number in a future version of PB/DLL? And what about being able to specify the ordinal numbers of exported functions in a PB/DLL program, e.g.
        Code:
        FUNCTION DoSomething( [i]argument list[/i] ) EXPORT #10
           ...
        END FUNCTION
         
        FUNCTION DoSomethingElse( [i]argument list[/i] ) EXPORT #20
           ...
        END FUNCTION
        If you try to make something idiot-proof, someone will invent a better idiot.

        Comment


        • #5
          [OOPS - redundant post - saw that Eric's earlier post showed
          exactly what I wrote - I'll leave it here for completeness...]

          Here's an API way to call functions by ordinal instead of by name.
          Note that to call a function/sub by ordinal the function/sub
          must still be exported.

          Code:
          #INCLUDE "win32api.inc"
           
          SUB ExportMe ALIAS "ExportMe" ( szValue AS ASCIIZ ) EXPORT
               
              PRINT "Received the value: " + szValue
               
          END SUB
           
          FUNCTION PBMAIN() AS LONG
              LOCAL dwAddress AS DWORD
              LOCAL hLib AS LONG
                
              'Note that using Ordinals is NOT recommended since ordinals may
              'change from build to build depending on code changes/functions,etc
               
              hLib = GetModuleHandle( BYVAL %NULL ) 'use LoadLibrary/LoadLibraryEx for external DLLs
              IF hLib THEN
                  dwAddress = GetProcAddress( hLib, BYVAL 1 )
                  IF dwAddress THEN
                      CALL DWORD dwAddress USING ExportMe( "HELLO ORDINAL")
                  END IF
                  'when using LoadLibrary don't forget to release it with FreeLibrary( hLib ) when done
              END IF
              WAITKEY$
          END FUNCTION
          Cheers

          Florent

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


          [This message has been edited by Florent Heyworth (edited May 03, 2001).]

          Comment


          • #6
            Note that using Ordinals is NOT recommended since ordinals may
            change from build to build depending on code changes/functions,etc
            Use of ordinal numbers to link to Windows API functions is definitely not recommended, as Microsoft just loves to change things in each new release of Windows.

            For ones own executables though, use of ordinal numbers may be a useful means of grouping related functions together so that when the list of exported functions is viewed by a program like Dependency Walker, they can be sorted by ordinal number and appear listed in logical groups rather than alphabetically by name. I'm sure there are other quite valid reasons why use of ordinal numbers may be preferrable.
            If you try to make something idiot-proof, someone will invent a better idiot.

            Comment


            • #7
              Tom, any chance it will be possible to statically link to exported functions by ordinal number in a future version of PB/DLL?
              And what about being able to specify the ordinal numbers of exported functions in a PB/DLL program
              Anything's possible. I'll make sure it's on the wish list.

              ------------------
              Tom Hanlin
              PowerBASIC Staff

              Comment


              • #8
                Thank you so much folks.

                Well if is not exported - no wonder
                The idea with the LoadLibrary() sounds pretty good to me
                and makes sense. I'll check that out.

                Thanks again
                Tom


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

                Comment

                Working...
                X