View previous topic :: View next topic |
Author |
Message |
silverdan
Joined: 14 May 2009 Posts: 29
|
Posted: Wed Mar 10, 2010 10:16 pm Post subject: Windows exectuable with WinMain |
|
|
Our existing F77 code base uses the following to create a windows executable:
Code: |
integer function WinMain( hInstance,hPrevInstance,lpCmdLine,
. nCmdShow)
use msfwina
! For Windows Execution
integer hInstance
integer hPrevInstance
integer lpCmdLine
integer nCmdShow
!MS$ ATTRIBUTES STDCALL ,ALIAS : '_WinMain@16' :: WinMain
!!!!!!! CODE !!!!!!!!!!!!!!!!!!!!!!!!
WinMain = 0
END
|
I see inside win32api.ins there is a "STDCALL WINMAIN 'WinMain' (VAL,VAL,STRING,VAL):INTEGER*4"
How can I convert the above code to use with FTN95 .Net to create a windows executable? |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8210 Location: Salford, UK
|
Posted: Thu Mar 11, 2010 11:44 am Post subject: |
|
|
There is no WinMain with FTN95.
For standard Fortran input/output you can put WINAPP on a line before the main Fortran program
Code: | WINAPP
program myprog
read*, n
print*, n
end |
This will give you a Windows IO window for either Win32 or .NET.
If you want to create a GUI for your program then there are three direct ways to do this...
1) Create a VB .NET form and access a FTN95 assembly (DLL)
2) Create a C# form and access a FTN95 assembly (DLL)
3) Use Silverfrost Visual ClearWin with FTN95
As it happens you can also use the Win32 ClearWin+ from .NET but this is not by design and cannot be guaranteed. In this case (image etc) resources have to be coded into a DLL. |
|
Back to top |
|
 |
silverdan
Joined: 14 May 2009 Posts: 29
|
Posted: Thu Mar 11, 2010 6:13 pm Post subject: |
|
|
Paul,
Does winapp have some sort of return code built-in similar to WinMain?
I am not trying to build a GUI exe in FTN95 .Net, but rather a program that gets called from another exe such as VB.
So the scenario is that a VB EXE uses the API GetExitCodeProcess to get the return code from API WinMain in the Fortran EXE.
We are currently using WinMain API in Fortran code to pass along the return code and would like to know how to do this in FTN95 .Net
There is an interface to WinMain inside win32api.ins
STDCALL WINMAIN 'WinMain' (VAL,VAL,STRING,VAL):INTEGER*4
If winapp does not provide a return code, could you give a little pointer on how to use WinMain in FTN95 .Net
Thanks,
Dan |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8210 Location: Salford, UK
|
Posted: Thu Mar 11, 2010 7:32 pm Post subject: |
|
|
WINAPP is not a function. It sets an attribute on the executable so that it is a Windows executable and not a console executable.
As far as I know, standard Fortran does not provide a way to return an error state to the operating system but FTN95 provides EXIT and EXIT@ for this purpose. |
|
Back to top |
|
 |
|