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
新規コントリビューター II
951件の閲覧回数
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 件の賞賛
3 返答(返信)
ggveldkamp2
初心者
951件の閲覧回数
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.
Jugoslav_Dujic
高評価コントリビューター II
951件の閲覧回数
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.
Steven_L_Intel1
従業員
953件の閲覧回数
This is probably an uninitialized variable error. See if the console window (behind the VS window most likely) has a more detailed message.
返信