NO

Author Topic: EXE file works in the IDE but not as standalone  (Read 3983 times)

omar

  • Guest
EXE file works in the IDE but not as standalone
« on: January 05, 2012, 12:23:46 AM »
I have a small program which uses a DLL library, I was able to make the .EXE file run while in the IDE but it does not work outside it.

Offline Stefan Pendl

  • Global Moderator
  • Member
  • *****
  • Posts: 582
    • Homepage
Re: EXE file works in the IDE but not as standalone
« Reply #1 on: January 05, 2012, 01:13:12 AM »
Are the EXE and DLL located in the same folder?

If not the EXE will not find the DLL.
---
Stefan

Proud member of the UltraDefrag Development Team

CommonTater

  • Guest
Re: EXE file works in the IDE but not as standalone
« Reply #2 on: January 05, 2012, 01:31:51 AM »
Even better question ...What exactly is it (not) doing?

If you clicking it in Windows Explorer and there's nothing to ask for input from the user, it's entirely possible it executs and closes so fast you don't see it.

Post your code... lets see what we can do...

omar

  • Guest
Re: EXE file works in the IDE but not as standalone
« Reply #3 on: January 05, 2012, 03:59:41 PM »
Yes the DLL and the ESE files are in the same directory.
When runnnig the EXE file it ends with an error message "An unhandled win32 exception ocurred in Monitor.exe"
The program is based on a Petzold example and I'm using it to read the CPU temperature through a library (Susi.dll and Susi.lib, the define file is called "REL_SUSI.h") distributed by the board manufacturer.
I am able to read and display the temperature when running the EXE file inside the IDE.
Here is the code:

#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <tchar.h>     
#include <stdio.h>   
#include "REL_SUSI.h"

int CDECL MessageBoxPrintf (TCHAR * szCaption, TCHAR * szFormat, ...)
{
     TCHAR   szBuffer [1024] ;
     va_list pArgList ;

          // The va_start macro (defined in STDARG.H) is usually equivalent to:
          // pArgList = (char *) &szFormat + sizeof (szFormat) ;

     va_start (pArgList, szFormat) ;

          // The last argument to wvsprintf points to the arguments

     _vsntprintf (szBuffer, sizeof (szBuffer) / sizeof (TCHAR),
                  szFormat, pArgList) ;

          // The va_end macro just zeroes out pArgList for no good reason

     va_end (pArgList) ;

     return MessageBox (NULL, szBuffer, szCaption, 0) ;
}

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                    PSTR szCmdLine, int iCmdShow)
{
     int cputemp, cyScreen ;
    float* dos;
   
    if (SusiDllInit())
   {
    SusiHWMGetTemperature(1,dos);
   }
    cputemp= *dos;
    MessageBoxPrintf (TEXT ("CPU temperature"),
                       TEXT ("The CPU temperature is %i degrees C"),
                       cputemp, cyScreen) ;
     return 0 ;
}

Offline Stefan Pendl

  • Global Moderator
  • Member
  • *****
  • Posts: 582
    • Homepage
Re: EXE file works in the IDE but not as standalone
« Reply #4 on: January 05, 2012, 04:26:11 PM »
I think your problem is the use of a pointer to float.

Code: [Select]
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                    PSTR szCmdLine, int iCmdShow)
{
     int cputemp, cyScreen ;
    float dos;
   
    if (SusiDllInit())
   {
    SusiHWMGetTemperature(1,&dos);
   }
    cputemp= (int)dos;
    MessageBoxPrintf (TEXT ("CPU temperature"),
                       TEXT ("The CPU temperature is %i degrees C"),
                       cputemp, cyScreen) ;
     return 0 ;
}

Try it with the changes above.
---
Stefan

Proud member of the UltraDefrag Development Team

omar

  • Guest
Re: EXE file works in the IDE but not as standalone
« Reply #5 on: January 06, 2012, 03:30:30 PM »
Thanks a lot Stefan it did work. I had also another mistake with an extra parameter after cputemp at the last text.