Cobol NetExpress 3.1

Dear sirs,

when I run the command:

call cc74 'FindFirstFileA'
using by reference findFileName *> lpFileName
by reference WIN32-FIND-DATA *> lpFindFileData
returning fileSearchHandle

I'm getting an error 173 Called program file not found in directory/drive

FindFirstFileA

How do I solve this

Att

Rogerio Barbosa

  • move ' ' to findfilename
    string link-csb-pfad delimited by ' '* '\' delimited by size
               'yourfilename.dat' x'00' delimited by size
              into findfilename
    end-string
    move 0 to i1
    move spaces to cFileName
    call winapi 'FindFirstFileA' using by reference findFileName *> lpFileName
                                                        by reference WIN32-FIND-DATA *> lpFindFileData
                                                        returning fileSearchHandle
    if fileSearchStatus <> -1 *> INVALID_HANDLE_VALUE
       perform convertFileTimeToLocalTime
       perform determineFileAttributes
       perform with test after until findNextStatus = 0
           move spaces to cFileName
           call winapi 'FindNextFileA' using by value fileSearchHandle *> hFindFile
                                                               by reference WIN32-FIND-DATA *> lpFindFileData
                                                               returning findNextStatus
           if findNextStatus <> 0
              perform convertFileTimeToLocalTime
               perform determineFileAttributes
           end-if
       end-perform

    call winapi 'FindClose' using by value fileSearchHandle *> hFindFile
                                        returning FindCloseStatus

    do you have add a x'00' for your filename?

  • Hi Rogerio.

    FindFirstFileA is a Windows API function which resides in the Windows Kernel32.dll which is found in either the Windows\System32 folder for 64-bit or the Windows\SysWOW64 folder if it is 32-bit. This should be found automatically.

    If you are creating an exe you should be linking to the kernel32.lib library which is part of the Windows SDK but is included with Net Express in the Lib folder.

    If you are running as .int or gnt then you should have the following call before your call to FindFirstFile

    call "cob32api"

    How are you building your executable and under what OS are you running?

    Chris Glazier
    Rocket Software - Principal Technical Support Specialist
    If you found this post useful, give it a “Like” or click on "Verify Answer" under the "More" button

  • RTS 173 means it can't find the called module or entry point you are trying to call. How is you target built and linked in NX 3.1?

    Most likely you probably need to load the kernell32.dll first to make the functions in it available. FindFirstFileA is a function/entry point in kernel32.dll

    try:

    In working storage:

    01 my-library procedure-pointer.

    and then:

    In procedure division:

    set my-library to entry "kernel32"  *> This will load the kernel32.dll which should be on the path"

  • Onde consigo a documentação da biblioteca cobapi32

    Atenciosamente

    Rogerio Barbosa

  • cob32api isn't documented very well. It shows up in a sample program and in the docs under Examples for calling a Windows API:

    Example of Calling a Win32 API Routine

    The following program makes use of an API routine to retrieve the current date and time.

     special-names.
         call-convention 74 is winapi.
     working-storage section. 
     01 system-time.
         03 system-year     pic 9(4) comp-5.
         03 system-month    pic 9(4) comp-5.
         03 system-day-of-week  pic 9(4) comp-5.
         03 system-day    pic 9(4) comp-5.
         03 system-hour    pic 9(4) comp-5.
         03 system-minute   pic 9(4) comp-5.
         03 system-second   pic 9(4) comp-5.
         03 system-millisecond  pic 9(4) comp-5.
    
     procedure division.
         call "cob32api"
         call winapi "GetSystemTime" using
                      by reference system-time
         display "Day of week is:  " system-day-of-week
         display "Day of month is:  " system-day
         stop run.

    Chris Glazier
    Rocket Software - Principal Technical Support Specialist
    If you found this post useful, give it a “Like” or click on "Verify Answer" under the "More" button