Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Problem with Win32 API

Jon_D
New Contributor II
638 Views
Hi,

I am in the process of converting a CVF project to IVF (compiler version 10.0.027 with VS2003). I am getting a run-time error in a subroutine where I check if a console has been opened or not for the application. The subroutine is as follows:

SUBROUTINE CheckConsoleAvailability()

!Local variables
LOGICAL::Status
INTEGER::fhandle
TYPE(T_CONSOLE_SCREEN_BUFFER_INFO) cinfo

!Check if a console is available
Status=GetConsoleScreenBufferInfo(fhandle,cinfo)
IF (Status) RETURN !Available, do nothing

!If not available create one
Status=AllocConsole()
fhandle=GetStdHandle(STD_OUTPUT_HANDLE)

END SUBROUTINE CheckConsoleAvailability


The subroutine is in a module. At the top of the module I have USE IFWIN. When I run the Release version of the executable it runs fine. When I run the Debug version of the executable, it runs fine as well. But when I use Debug/Start from the VS2003 I get a window that says "Unhandled exception at 0x00500a2a in processor4_0.exe: User breakpoint." at line

Status=GetConsoleScreenBufferInfo(fhandle,cinfo)

When I comment out this line and do the same (Debug/Start) this time I get the same error at the next line (IF (Status) RETURN). When this line is also commented out, the program runs fine.

Does anybody have any idea what might be the problem here? Thanks for any replies in advance.

Jon
0 Kudos
3 Replies
ggveldkamp2
Novice
638 Views
The fhandle argument of GetConsoleScreenBufferInfo is input so it needs to have a value before calling the function. Maybe it is better to use the GetConsoleWindow function.
0 Kudos
Jugoslav_Dujic
Valued Contributor II
638 Views
ggveldkamp2:
The fhandle argument of GetConsoleScreenBufferInfo is input so it needs to have a value before calling the function. Maybe it is better to use the GetConsoleWindow function.


No, it's a HANDLE, not a HWND. However, GetStdHandle(STD_OUTPUT_HANDLE) should do the job instead.
0 Kudos
Steven_L_Intel1
Employee
640 Views
This is probably an uninitialized variable error. See if the console window (behind the VS window most likely) has a more detailed message.
0 Kudos
Reply