Jump to content

KernClose: Difference between revisions

From EDM2
No edit summary
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
"KernOpen()", "KernClose()", "KernRead()" are functions from KEE32 intended to read text files with settings during a boot time, such as "Protocol.ini"
"KernOpen()", "KernClose()", "KernRead()" are functions from KEE32 intended to read text files with settings during a boot time, such as "Protocol.ini"
----
;AI Generated


KernClose is a function that is used to close a file or other input/output (I/O) stream. It takes a handle to an open file or stream as a parameter and closes the file or stream.
KernClose is a function that is used to close a file or other input/output (I/O) stream. It takes a handle to an open file or stream as a parameter and closes the file or stream.


==Syntax==
==Syntax==
Here is the definition of the KernClose function:
unsigned long KernClose( HFILE hFile );
 
unsigned long KernClose(
  HFILE hFile
);


==Parameters==
==Parameters==
The function takes a single parameter:
The function takes a single parameter:


    hFile: A handle to an open file or stream that was returned by a function such as KernOpen or KernDup.
;hFile ([[HFILE]]) - input: A handle to an open file or stream that was returned by a function such as KernOpen or KernDup.


==Return Value==
==Return Value==
Line 20: Line 19:
==Sample==
==Sample==
Here is an example of how KernClose might be used in a program:
Here is an example of how KernClose might be used in a program:
 
<PRE>
#include <os2.h>
#include <os2.h>


Line 45: Line 44:
   return 0;
   return 0;
}
}
 
</PRE>
In this example, the KernClose function is used to close a file that was previously opened for reading using the DosOpen function. The handle to the open file is passed as a parameter to KernClose, and the function returns zero on success or an error code if an error occurred.
In this example, the KernClose function is used to close a file that was previously opened for reading using the DosOpen function. The handle to the open file is passed as a parameter to KernClose, and the function returns zero on success or an error code if an error occurred.


[[Category:KEE]]
[[Category:KEE]]

Latest revision as of 03:11, 28 May 2025

"KernOpen()", "KernClose()", "KernRead()" are functions from KEE32 intended to read text files with settings during a boot time, such as "Protocol.ini"


AI Generated

KernClose is a function that is used to close a file or other input/output (I/O) stream. It takes a handle to an open file or stream as a parameter and closes the file or stream.

Syntax

unsigned long KernClose( HFILE hFile );

Parameters

The function takes a single parameter:

hFile (HFILE) - input
A handle to an open file or stream that was returned by a function such as KernOpen or KernDup.

Return Value

The KernClose function returns zero on success or an error code if an error occurred.

Sample

Here is an example of how KernClose might be used in a program:

#include <os2.h>

int main() {
   HFILE hFile;
   ULONG ulAction;

   // Open a file for reading
   if (DosOpen("c:\\example.txt", &hFile, &ulAction, 0,
               FILE_NORMAL, FILE_OPEN,
               OPEN_ACCESS_READONLY | OPEN_SHARE_DENYNONE, NULL)) {
      // An error occurred
      return -1;
   }

   // Do something with the file

   // Close the file
   if (KernClose(hFile)) {
      // An error occurred
      return -1;
   }

   return 0;
}

In this example, the KernClose function is used to close a file that was previously opened for reading using the DosOpen function. The handle to the open file is passed as a parameter to KernClose, and the function returns zero on success or an error code if an error occurred.