Jump to content

DosOpenVDD: Difference between revisions

From EDM2
Created page with "==Description== Opens a virtual device driver (VDD), and returns a handle for it. ==Syntax== <PRE> #define INCL_DOSMVDM #include <os2.h> PSZ pszVDD; /* The ASCIIZ na..."
 
Ak120 (talk | contribs)
mNo edit summary
Line 7: Line 7:
#include <os2.h>
#include <os2.h>


PSZ      pszVDD;  /* The ASCIIZ name of the virtual device driver to be opened. */
PSZ      pszVDD;  /* The ASCIIZ name of the virtual device driver to be opened. */
PHVDD    phvdd;  /* A pointer to the HVDD in which the handle of the virtual device driver is returned. */
PHVDD    phvdd;  /* A pointer to the HVDD in which the handle
APIRET    ulrc;    /* Return Code. */
                      of the virtual device driver is returned. */
APIRET    ulrc;    /* Return Code. */


ulrc = DosOpenVDD(pszVDD, phvdd);
ulrc = DosOpenVDD(pszVDD, phvdd);
</PRE>


</PRE>
==Parameters==
==Parameters==
; pszVDD (PSZ) - input : The ASCIIZ name of the virtual device driver to be opened.  
;pszVDD (PSZ) - input : The ASCIIZ name of the virtual device driver to be opened.
 
; phvdd (PHVDD) - output : A pointer to the HVDD in which the handle of the virtual device driver is returned.
; phvdd (PHVDD) - output : A pointer to the HVDD in which the handle of the virtual device driver is returned.


==Return Code==
==Return Code==
; ulrc (APIRET) - returns
;ulrc (APIRET) - returns


DosOpenVDD returns one of the following values:
DosOpenVDD returns one of the following values:
* 0  NO_ERROR
* 643 ERROR_VDD_NOT_FOUND
* 644 ERROR_INVALID_CALLER


* 0          NO_ERROR
* 643        ERROR_VDD_NOT_FOUND
* 644        ERROR_INVALID_CALLER
==Remarks==
==Remarks==
DosOpenVDD opens a virtual device driver, and returns a handle for it.
DosOpenVDD opens a virtual device driver, and returns a handle for it.
Line 38: Line 38:


This example shows a protected-mode process calling a hypothetical VDD with a request to read a string of bytes from the VDD. Assume that the session identifier of the specified DOS session has been placed into SessionID already and that the sample virtual device driver has registered the name "VDD007" with the operating system.
This example shows a protected-mode process calling a hypothetical VDD with a request to read a string of bytes from the VDD. Assume that the session identifier of the specified DOS session has been placed into SessionID already and that the sample virtual device driver has registered the name "VDD007" with the operating system.
<PRE>
<PRE>
  #define INCL_DOSMVDM    /* Multiple DOS sessions values */
  #define INCL_DOSMVDM    /* Multiple DOS sessions values */
Line 76: Line 75:
         return 1;
         return 1;
     }
     }
</PRE>


</PRE>
==Related Functions==
==Related Functions==
* [[OS2 API:CPI:DosCloseVDD|DosCloseVDD]]
*[[DosCloseVDD]]
* [[OS2 API:CPI:DosRequestVDD|DosRequestVDD]]
*[[DosRequestVDD]]
 


[[Category:The OS/2 API Project]]
[[Category:Dos]]

Revision as of 16:10, 6 December 2016

Description

Opens a virtual device driver (VDD), and returns a handle for it.

Syntax

#define INCL_DOSMVDM
#include <os2.h>

PSZ       pszVDD;  /* The ASCIIZ name of the virtual device driver to be opened. */
PHVDD     phvdd;   /* A pointer to the HVDD in which the handle
                      of the virtual device driver is returned. */
APIRET    ulrc;    /* Return Code. */

ulrc = DosOpenVDD(pszVDD, phvdd);

Parameters

pszVDD (PSZ) - input
The ASCIIZ name of the virtual device driver to be opened.
phvdd (PHVDD) - output
A pointer to the HVDD in which the handle of the virtual device driver is returned.

Return Code

ulrc (APIRET) - returns

DosOpenVDD returns one of the following values:

  • 0 NO_ERROR
  • 643 ERROR_VDD_NOT_FOUND
  • 644 ERROR_INVALID_CALLER

Remarks

DosOpenVDD opens a virtual device driver, and returns a handle for it.

If pszVDD specifies the name of an OS/2 virtual device driver, the returned handle allows an OS/2 protected-mode application to communicate with a virtual device driver by issuing DosRequestVDD.

Issue DosCloseVDD to close the handle of the virtual device driver.

Example Code

The following is NOT a complete C program. It is simply intended to provide an idea of how a protected-mode OS/2 process can communicate with a virtual device driver (VDD).

This example shows a protected-mode process calling a hypothetical VDD with a request to read a string of bytes from the VDD. Assume that the session identifier of the specified DOS session has been placed into SessionID already and that the sample virtual device driver has registered the name "VDD007" with the operating system.

 #define INCL_DOSMVDM     /* Multiple DOS sessions values */
 #define INCL_DOSERRORS   /* DOS Error values */
 #include <os2.h>
 #include <stdio.h>

 UCHAR   VDDName[10] = "VDD007";    /* Name of VDD */
 HVDD    VDDHandle   = NULLHANDLE;  /* Handle of VDD */
 SGID    SessionID   = 0;        /* Session identifier (should be initialized */
 ULONG   Command     = 3;        /* VDD function code (hypothetical) */
 APIRET  rc          = NO_ERROR;    /* Return code */
 UCHAR   InputBuffer[30]  = "Your command here";  /* Command information    */
 UCHAR   OutputBuffer[30] = "";                   /* Output data (returned) */

    rc = DosOpenVDD(VDDName, &VDDHandle);
    if (rc != NO_ERROR) {
       printf("VDD %s was not found.\n", rc);
       return 1;
    }

    rc = DosRequestVDD(VDDHandle,              /* Handle of VDD */
                       SessionID,              /* Session ID */
                       Command,                /* Command to send to VDD */
                       sizeof(InputBuffer),    /* Length of input */
                       InputBuffer,            /* Input buffer */
                       sizeof(OutputBuffer),   /* Length of output area */
                       OutputBuffer);          /* Output from command */
    if (rc != NO_ERROR) {
        printf("DosRequestVDD error: return code = %u\n", rc);
        return 1;
    }

    rc = DosCloseVDD(VDDHandle);               /* Close the VDD */
    if (rc != NO_ERROR) {
        printf("DosCloseVDD error: return code = %u\n", rc);
        return 1;
    }

Related Functions