1. A case of really bad c_func

--------------Boundary-00=_5NGQG6G0000000000000
  charset="iso-8859-1"

new topic     » topic index » view message » categorize

2. Re: A case of really bad c_func

Hi Travis,
I think this might be the problem...

If you use registerw32Function() you must use w32Func() and not c_func(),

----
Derek.

----- Original Message -----
From: "Travis Beaty" <travisbeaty at arn.net>
To: "EUforum" <EUforum at topica.com>
Sent: Tuesday, August 28, 2001 1:35 AM
Subject: A case of really bad c_func



Howdy y'all!

Well, I'm now extremely close to finishing the Windows Installer; in fact, I
m down to the last task that the installer has to perform, that of
restarting the machine.

I figured there were two ways I could do this.  As soon as everything is
finished installing, I could issue a message box stating, "OH NUTS!  QUICK!
HIT CONTROL+ALT+DELETE!" but I felt this would cause undo panic, and make
the user think that I live in Redmond, Washington.  So instead, I tried to
link with the Windows API function ExitWindowsEx().

Here are the three statements leading up to my definition of the atom
aExitWindowsEx:

-- start of code

-- BOOL RemoveDirectory(LPCTSTR lpPathName);
aRemoveDirectory = registerw32Function(kernel32, "RemoveDirectoryA",
{C_POINTER}, C_ULONG)

-- DWORD GetLogicalDriveStrings(DWORD nBufferLength, LPTSTR lpBuffer);
aGetLogicalDriveStrings = registerw32Function(kernel32,

GetLogicalDriveStringsA",   {C_ULONG, C_POINTER}, C_ULONG)

-- BOOL ExitWindowsEx(UINT nflags, DWORD nReserved);
aExitWindowsEx = registerw32Function(user32, "ExitWindowsExA", {C_INT,
C_ULONG}, C_INT)

-- end of code

Later, in closedown(), I attempt to use this ...

-- start of code
----------------------
procedure closedown()
----------------------
    integer
        iAns,
        iExitResult
    db_close()
    setText(lblProgress, "Cleaning up house ...")
    openWindow(frmProgress, Normal)
    if delTree(TEMP_PATH) then
        addLogEntry("Cleaned up all of the temporary files")
    else
        addLogEntry("Unable to clean up temporary files")
    end if
    iAns = message_box(
        "In order to complete the installation of Euphoria, your machine
must now be restarted.  This " &
        "is done so that the modified autoexec.bat file is recognized by
Windows.  Euphoria may not " &
        "work properly until the machine is restarted.  May the installer
reboot your machine at this " &
        "time?", APPNAME, MB_YESNO + MB_ICONQUESTION)
    if iAns = IDYES then
        addLogEntry("Restarted user's machine.")
    else
        addLogEntry("User declined restart.")
    end if
    writeLogFile(gsInstallDir & LOG_FILE)
   iExitResult = c_func(aExitWindowsEx, {2, 0})  -- EWX_REBOOT = 2
    if not iExitResult then
        iAns = message_box(
            "The installer was unable to make your system restart.
Therefore, you will need to restart " &
            "your system manually at this time.", APPNAME, MB_ICONERROR)
    end if
    giFinalExit = True
    addLogEntry("Failed to execute restart.")
    closeWindow(frmMain)
end procedure

-- end code

At this point, Euphoria complains about a bad routine number.  I have
attached the ex.err file.  Unfortunately, this is one of those *extremely
rare* times that a Euphoria error message leaves me in a state of complete
bafflement.  I have checked, and the routine number does not appear to have
been changed by my code before use.

I'm pretty sure this isn't a problem with define_c_func, because looking in
the docs, it passes a -1 if it cannot link to the function.  So the problem
is most likely either in my code (the most likely case) or within the
innards of win32lib.ew (remote but possible).

Any thoughts, solutions, medications?


Travis Beaty
aka Palo Duro Solutions

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu