Rewriting a Win32 app using HINSTANCE to a Win32 console application
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: Rewriting a Win32 app using HINSTANCE to a Win32 console application

  1. #1
    Join Date
    Dec 2012
    Posts
    3

    Rewriting a Win32 app using HINSTANCE to a Win32 console application

    Hi Everyone,

    First let me that the last time I did a Vc++ small utility prg is back in 1995.
    Here is my situation:
    I have a win32 app that uses HINSTANCE and the main.cpp looks like:
    -----------------------
    #include "stdafx.h"
    #include "testlib.c"

    int APIENTRY WinMain(HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPSTR lpCmdLine,
    int nCmdShow)
    {
    LoadTestLibrary();
    // etc....
    }
    ----------------
    the testlib.c looks like this:
    -----------------
    HINSTANCE TESTLIB=NULL;

    long LoadTestLibrary()
    {
    TESTLIB=LoadLibrary("TESTLIB.DLL");
    if(TESTLIB == NULL)
    {
    MessageBox(NULL, "Unable to load TESTLIB.DLL", "ERROR", MB_OK);
    return(-1);
    }
    else
    {
    // do some stuff...
    }
    -----------------
    What I want is rewrite the code in a win32 console app. all output will be echoed instead of messagebox. The reason I want a console app is because I need to compile it with mono and use it on a linux server.
    The TESTLIB.DLL is an external library that is supposed to be compiled in .NET.

    Any help will be appreciated, if someone is interested to do the work for me, please PM me I can give you the source code and you can give me an estimate price.
    Thanks

  2. #2
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,642

    Re: Rewriting a Win32 app using HINSTANCE to a Win32 console application

    I might have forgot something here but...

    It should be just a matter of changing WinMain to a standard main and change the project settings to a console project.
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    http://www.microsoft.com/visualstudio/eng/downloads

  3. #3
    Join Date
    Feb 2002
    Posts
    4,640

    Re: Rewriting a Win32 app using HINSTANCE to a Win32 console application

    And change calls to 'MessageBox' to instead write to the output stream ("cout").

    Viggy

  4. #4
    Join Date
    Dec 2012
    Posts
    3

    Re: Rewriting a Win32 app using HINSTANCE to a Win32 console application

    Someone said that this:
    "The OCR component is a Win32 DLL, to which Mono can't do anything to run on Linux. Mono is a pure implementation of the MSIL and CIL on various platforms. I can't run native Win32 components on other platforms. For example, the code file you attached uses the LoadLibrary and GetProcAddress which are Windows API functions that won't execute on Linux.

    Is it true ?

  5. #5
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    11,480

    Re: Rewriting a Win32 app using HINSTANCE to a Win32 console application

    Quote Originally Posted by peterman View Post
    Someone said that this:
    "The OCR component is a Win32 DLL, to which Mono can't do anything to run on Linux. Mono is a pure implementation of the MSIL and CIL on various platforms. I can't run native Win32 components on other platforms. For example, the code file you attached uses the LoadLibrary and GetProcAddress which are Windows API functions that won't execute on Linux.

    Is it true ?
    Mono allows you to run .net applications on Linux which doesn't have anything to do with running a native 32 app. What are you trying to do exactly?

  6. #6
    Join Date
    Dec 2012
    Posts
    3

    Re: Rewriting a Win32 app using HINSTANCE to a Win32 console application

    I have a webserver running on linux (running PHP), I need a handwriting recognition library to decode part of an image that is stamped with some handwriting characters, so I looked all over the internet and only found 2 third party libraries but they are only available as DLL so I need to find a way to use these DLL on linux. if it can not not be done, then I would need a win32 webapp that will run as a window service and that will listen on port XXX. I will be sending an HTTP POST (a JSON string that will contain the Image in BMP format encoded in Base64, with the command like "RecognizeLine,RecognizeWord" etc) and then the webapp will respond also in JSON format with the results.
    I would prefer a console app that I will call via PHP from my webserver (send a JSON stream and getback a JSON response). I ratter not use wine.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center