Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8006511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:32:05+00:00 2026-06-04T17:32:05+00:00

How do i call this method from java : WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,

  • 0

How do i call this method from java :

 WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)

Is it possible to call WinMain from java ? I want the value of the arguments in that function be same as when directly running a c++ program. I want to link a .dll whose entry point be this function.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T17:32:06+00:00Added an answer on June 4, 2026 at 5:32 pm

    It is a bad idea, for multiple reasons.

    WinMain is special

    Like main or DllMain, those functions have more to say than it appears.

    Contrarily to the naive approach, WinMain is not the "first" function on the stack. It is the first function writeable by the code developer. But if you go in debug, you’ll see that there is a lot going on before and after WinMain.

    Among them, construction/destruction of C++ global objects, functions registered with the atexit C API, etc., but you can be sure there’s a lot happening there that is specific to the Windows platform.

    Then, if it is a WinMain, chances are you have a message loop somewhere inside. It could well interfere with your own (is your Java application a GUI app?)

    HINSTANCE is not optional

    What parameter values will you give WinMain?

    The first HINSTANCE parameter is quite important and could be used by the code of the executable you’re trying to launch. You can’t just feed some random value and expect it to work. You could retrieve the HINSTANCE of your Java process, but I suspect you wouldn’t like the result.

    Hidden variables are not optional

    Let’s say you succeed in calling the WinMain of a program. This program will expect some things to be there (see the WinMain is special section). Among them, the result of the GetCommandLine() API function, that could be used in your C++ program.

    WinMain is for processes, not DLLs

    Is it possible to call WinMain from java ? I want the value of the arguments in that function be same as when directly running a c++ program. I want to link a .dll whose entry point be this function

    Are you trying to "launch" a DLL, whose entrypoint is WinMain? I guess there’s something wrong somewhere. WinMain or main are the standard entrypoints on Windows for processes, not DLLs. A DLL entry point is usually DllMain which have a different prototype.

    Conclusion

    I don’t know why you need to launch your executable in the same process than your Java launcher, but I believe you’re doing something wrong.

    Like mikera wrote in his answer, you’d better use the Java API to launch a process.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In the JSNI example to call a Java method from Javascript, they write this:
I'm trying to call the java code from S. This method call: cls =
i hava a c++ method(for java,jni) like follow,when i repeat call this from java
Shouldn't I be able to call this CoffeeScript method from within an erb template?
I have this question: How could I call a codebehind method from jquery? I
I have a problem when call applet method from javascript.. I used this function
This one has me stumped. I need to call an activity method from within
I'm getting a java outOfMemoryError when I call this method - i'm using it
I'm stuck with this, I need to call a Java Function from c/c++. In
How can I call a method with this method signature in C from JNA?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.