本文整理汇总了C++中DosOpen函数的典型用法代码示例。如果您正苦于以下问题:C++ DosOpen函数的具体用法?C++ DosOpen怎么用?C++ DosOpen使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DosOpen函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CMD_DosOpen
//-------------------------------- CMD_DosOpen ---------------------------------
void CMD_DosOpen(HFILE hFile,LXIOCPA_DMN_CMDPARMPACKET* pParam
,PLXDOSOPENSTRUCT p)
{
pParam->rc=DosOpen(p->fileName,&p->hFile,&p->ulAction,p->cbFile
,p->ulAttribute,p->fsOpenFlags,p->fsOpenMode
,NULL);
}
示例2: OpenPort
BOOL OpenPort(THREAD *pstThd)
{
ULONG ulAction;
APIRET rc;
CHAR szMsgString[200];
CHAR szCaption[80];
if ((rc = DosOpen(pstThd->stCfg.szPortName,&pstThd->hCom,&ulAction,0L,0,0x0001,0x21c2,0L)) != 0)
{
WinQueryWindowText(pstThd->hwndFrame,sizeof(szCaption),szCaption);
// WinLoadString(pstThd->habAnchorBlk,NUL,EATM_DOSOPEN,
// sizeof(szMsgString),szMsgString);
sprintf(szMsgString,"Error opening %s\nError Code = %04X",pstThd->stCfg.szPortName,rc);
WinMessageBox( HWND_DESKTOP,
pstThd->hwndDlg,
(PSZ)szMsgString,
(PSZ)szCaption,
NUL,
MB_MOVEABLE | MB_OK | MB_CUAWARNING );
pstThd->hCom = 0;
return(FALSE);
}
return(TRUE);
}
示例3: GA_getSharedInfo
/****************************************************************************
REMARKS:
This function returns a pointer to the common graphics driver loaded in the
helper VxD. The memory for the VxD is shared between all processes via
the VxD, so that the VxD, 16-bit code and 32-bit code all see the same
state when accessing the graphics binary portable driver.
****************************************************************************/
GA_sharedInfo * NAPI GA_getSharedInfo(
int device)
{
/* Initialise the PM library and connect to our runtime DLL's */
PM_init();
/* Open our helper device driver */
if (DosOpen(PMHELP_NAME,&hSDDHelp,&result,0,0,
FILE_OPEN, OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE,
NULL))
PM_fatalError("Unable to open SDDHELP$ helper device driver!");
outLen = sizeof(result);
DosDevIOCtl(hSDDHelp,PMHELP_IOCTL,PMHELP_GETSHAREDINFO,
NULL, 0, NULL,
&result, outLen, &outLen);
DosClose(hSDDHelp);
if (result) {
/* We have found the shared Nucleus packet. Because not all processes
* map to SDDPMI.DLL, we need to ensure that we connect to this
* DLL so that it gets mapped into our address space (that is
* where the shared Nucleus packet is located). Simply doing a
* DosLoadModule on it is enough for this.
*/
HMODULE hModSDDPMI;
char buf[80];
DosLoadModule((PSZ)buf,sizeof(buf),(PSZ)"SDDPMI.DLL",&hModSDDPMI);
}
return (GA_sharedInfo*)result;
}
示例4: DosKillFastIo
APIRET
DosKillFastIo( PID pid )
{
APIRET rc;
HFILE hfd;
ULONG action, plen;
if(( rc = DosOpen((PSZ)"/dev/fastio$", (PHFILE)&hfd,
(PULONG)&action, (ULONG)0, FILE_SYSTEM, FILE_OPEN,
OPEN_SHARE_DENYNONE | OPEN_FLAGS_NOINHERIT | OPEN_ACCESS_READONLY,
(ULONG)0)) != NO_ERROR )
{
return rc;
}
if(( rc = DosDevIOCtl( hfd, (ULONG)0x76, (ULONG)0x65,
(PULONG*)&pid, sizeof(USHORT), &plen, NULL, 0, NULL)) != 0 )
{
DosClose( hfd );
return rc;
}
DosClose(hfd);
return NO_ERROR;
}
示例5: LocalOpen
sys_handle LocalOpen( char *name, open_access access )
{
HFILE hdl;
USHORT action;
USHORT openflags;
USHORT openmode;
USHORT rc;
if( (access & OP_WRITE) == 0 ) {
openmode = READONLY;
access &= ~(OP_CREATE|OP_TRUNC);
} else if( access & OP_READ ) {
openmode = READWRITE;
} else {
openmode = WRITEONLY;
}
openmode |= 0x20c0;
openflags = 0;
if( access & OP_CREATE ) openflags |= 0x10;
openflags |= (access & OP_TRUNC) ? 0x02 : 0x01;
rc = DosOpen( name, /* name */
&hdl, /* handle to be filled in */
&action, /* action taken */
0, /* initial allocation */
0, /* normal file */
openflags, /* open the file */
openmode, /* deny-none, inheritance */
0 ); /* reserved */
if( rc != 0 ) {
StashErrCode( rc, OP_LOCAL );
return( NIL_SYS_HANDLE );
}
return( hdl );
}
示例6: _wpi_filecreate
HFILE _wpi_filecreate( LPSTR filename, int format )
/*************************************************/
{
#if 0 // this definition seems to interfere with C lib IO
PM1632_FILESIZETYPE action;
HFILE hfile;
if( !(format & (OPEN_SHARE_DENYREAD | OPEN_SHARE_DENYWRITE
| OPEN_SHARE_DENYREADWRITE | OPEN_SHARE_DENYNONE)) ) {
format |= OPEN_SHARE_DENYNONE;
}
if( DosOpen( (PSZ)filename, &hfile, &action, 0L, FILE_NORMAL,
OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS,
format, 0L ) != 0 ) {
hfile = -1;
}
#ifdef __FLAT__
DosDevIOCtl( hfile, 0x08, 0x00, 0, 0, 0, 0, 512L, 0 );
#else
// I don't know what to do here!
// DosDevIOCtl( hfile, 0x08, 0x00, 0, 0, 0, 0, 512L, 0 );
#endif
return( hfile );
#else
return( _wpi_fileopen( filename, format ) );
#endif
} /* _wpi_filecreate */
示例7: FcbGetFileSize
BOOL FcbGetFileSize(xfcb FAR * lpXfcb)
{
COUNT FcbDrive, hndl;
/* Build a traditional DOS file name */
lpFcb = CommonFcbInit(lpXfcb, SecPathName, &FcbDrive);
/* check for a device */
if (IsDevice(SecPathName) || (lpFcb->fcb_recsiz == 0))
{
return FALSE;
}
hndl = DosOpen(SecPathName, O_RDONLY);
if (hndl >= 0)
{
LONG fsize;
/* Get the size */
fsize = DosGetFsize(hndl);
/* compute the size and update the fcb */
lpFcb->fcb_rndm = fsize / lpFcb->fcb_recsiz;
if ((fsize % lpFcb->fcb_recsiz) != 0)
++lpFcb->fcb_rndm;
/* close the file and leave */
return DosClose(hndl) == SUCCESS;
}
else
return FALSE;
}
示例8: death
static
APIRET death(PID pid)
{
APIRET rc;
HFILE hfd;
ULONG action,plen;
USHORT param;
if ((rc=DosOpen((PSZ)"/dev/fastio$", (PHFILE)&hfd, (PULONG)&action,
(ULONG)0, FILE_SYSTEM, FILE_OPEN,
OPEN_SHARE_DENYNONE|OPEN_FLAGS_NOINHERIT|OPEN_ACCESS_READONLY,
(ULONG)0))) {
fputs("Error opening fastio$ driver...\n",stderr);
fputs("Please install xf86sup.sys in config.sys!\n",stderr);
return rc;
}
param = pid;
if ((rc=DosDevIOCtl(hfd, (ULONG)0x76, (ULONG)0x65,
(PULONG*)¶m,sizeof(USHORT),&plen,
NULL, 0, NULL)) != 0) {
fprintf(stderr,"fastio$ driver: kill(%i,9) failed rc=%i\n",pid,rc);
DosClose(hfd);
return rc;
}
DosClose(hfd);
return 0;
}
示例9: main
void main()
{
USHORT rc, Action;
HFILE FileHandle;
DosSetSigHandler(BrkHandler, NULL, NULL, SIGA_ACCEPT, SIG_CTRLC);
DosSetSigHandler(BrkHandler, NULL, NULL, SIGA_ACCEPT, SIG_KILLPROCESS);
DosSetSigHandler(BrkHandler, NULL, NULL, SIGA_ACCEPT, SIG_CTRLBREAK);
DosSetPrty(PRTYS_PROCESS, PRTYC_IDLETIME, 0, 0);
rc = DosOpen("Idlehlt$", &FileHandle, &Action, 0L,
FILE_NORMAL, FILE_OPEN, OPEN_SHARE_DENYNONE, 0L);
if(!rc) {
while(!ExitWhile)
DosDevIOCtl(NULL, NULL, 0x01, 0x91, FileHandle);
DosClose(FileHandle);
} else {
char buf[6], Message[36] = "HLT Driver not installed? rc=";
char *src = buf, *dst = &Message[29];
int len;
utoa(rc, buf, 10);
while(*dst++ = *src++);
len = dst - Message;
Message[len-1] = '\r';
Message[len] = '\n';
DosWrite(STDERR_FILENO, Message, len+1, &Action);
}
}
示例10: _dos_open
_WCRTLINK unsigned _dos_open( const char *name, unsigned mode, int *handle )
{
APIRET rc;
OS_UINT rwmode, actiontaken, openmode;
HFILE fhandle;
int share;
unsigned iomode_flags;
while( *name == ' ' ) ++name;
rwmode = mode & OPENMODE_ACCESS_MASK;
if( rwmode == OPENMODE_ACCESS_WRONLY
#if defined(__OS2_286__)
&& !_RWD_osmode
/* Can't open WRONLY file in bound application under DOS */
#endif
) {
rwmode = OPENMODE_ACCESS_RDWR;
}
share = mode & OPENMODE_SHARE_MASK;
if( share == OPENMODE_DENY_COMPAT ) {
share = OPENMODE_DENY_NONE;
}
openmode = share+rwmode;
rc = DosOpen( (PSZ)name, &fhandle, &actiontaken, 0ul,
_A_NORMAL, OPENFLAG_OPEN_IF_EXISTS, openmode, 0ul );
if( rc ) {
return( __set_errno_dos_reterr( rc ) );
}
*handle = fhandle;
if( rwmode == O_RDWR ) iomode_flags = _READ | _WRITE;
if( rwmode == O_RDONLY) iomode_flags = _READ;
if( rwmode == O_WRONLY) iomode_flags = _WRITE;
__SetIOMode( fhandle, iomode_flags );
return( 0 );
}
示例11: os2err
void *__PHYSFS_platformOpenAppend(const char *filename)
{
ULONG dummy = 0;
HFILE hfile = NULLHANDLE;
APIRET rc;
/*
* File must be opened SHARE_DENYWRITE and ACCESS_READWRITE, otherwise
* DosQueryFileInfo() will fail if we try to get a file length, etc.
*/
rc = os2err(DosOpen(filename, &hfile, &dummy, 0, FILE_NORMAL,
OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW,
OPEN_FLAGS_FAIL_ON_ERROR | OPEN_FLAGS_NO_LOCALITY |
OPEN_FLAGS_NOINHERIT | OPEN_SHARE_DENYWRITE |
OPEN_ACCESS_READWRITE, NULL));
if (rc == NO_ERROR)
{
if (os2err(DosSetFilePtr(hfile, 0, FILE_END, &dummy)) != NO_ERROR)
{
DosClose(hfile);
hfile = NULLHANDLE;
} /* if */
} /* if */
return((void *) hfile);
} /* __PHYSFS_platformOpenAppend */
示例12: Krnl_Debug_Log
// Title и String - строки, которые надо записать.
VOID Krnl_Debug_Log( PCHAR Title, PCHAR String )
{
// Если файла нет - создаем его.
HFILE File = NULLHANDLE; ULONG Report = 0; ULONG New_size = 0; PEAOP2 EAs = NULL;
ULONG Action = OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW;
ULONG Mode = OPEN_FLAGS_FAIL_ON_ERROR | OPEN_SHARE_DENYWRITE | OPEN_ACCESS_WRITEONLY;
CHAR Log_file_name[ SIZE_OF_PATH ] = "";
GetCurrentPath( Log_file_name ); strcat( Log_file_name, "\\_log.txt" );
DosOpen( Log_file_name, &File, &Report, New_size, FILE_COMMON_ATTRIBUTES, Action, Mode, EAs );
// Записываем строку.
if( Report != FILE_CREATED )
{
DosSetFilePtr( File, 0, FILE_END, &Report );
DosWrite( File, "\n", strlen( "\n" ), &Report );
}
if( Title[ 0 ] != 0 )
{
DosWrite( File, Title, strlen( Title ), &Report );
DosWrite( File, ": ", strlen( ": " ), &Report );
}
DosWrite( File, String, strlen( String ), &Report );
// Закрываем файл.
DosClose( File ); File = NULLHANDLE;
// Возврат.
return;
}
示例13: CreateFile
HFILE CreateFile(int iNr)
{
BYTE szFileName[20];
HFILE hFile;
#ifdef __IBMC__
APIRET rc;
ULONG ulAction;
#else
USHORT rc;
USHORT ulAction;
#endif
sprintf(szFileName, "FILE%4.4u.DAT", iNr);
rc = DosOpen(szFileName,
&hFile,
&ulAction,
0L, /* new size */
0, /* attributes */
FILE_CREATE | FILE_TRUNCATE,
OPEN_ACCESS_READWRITE | OPEN_SHARE_DENYNONE,
0L);
if (rc)
{
printf("DosOpen on %s failed, rc = %u\n", szFileName, rc);
getch();
return 0;
}
return hFile;
}
示例14: DosClose
char *ParsePortSpec( char * *spec )
{
char *parm;
ULONG action;
char port;
static char name[] = "com?";
parm = (spec == NULL) ? "" : *spec;
port = '1';
if( *parm >= '1' && *parm <= '9' ) {
port = *parm++;
}
if( *parm != '\0' && *parm != '.' ) return( TRP_ERR_invalid_serial_port_number );
if( spec != NULL ) *spec = parm;
if( ComPort != 0 ) {
DosClose( ComPort );
ComPort = 0;
}
name[sizeof( name ) - 2] = port;
if( DosOpen( (PSZ)name, &ComPort, &action, 0, 0, 1, 0x12, 0 ) ) {
ComPort = 0;
return( TRP_ERR_serial_port_not_available );
}
return( NULL );
}
示例15: while
char far *InitAlias( char far * inname )
/**************************************/
{
USHORT hdl,read;
static char b[80];
char *bp;
unsigned long ppos,pos;
USHORT action;
char far *endname;
static char noalias = 0;
endname = inname;
while( *endname == ' ' ) ++endname;
for( ;; ) {
if( *endname == '\0' ) {
break;
}
if( *endname == ' ' ) {
*endname = '\0';
++endname;
break;
}
++endname;
}
bp = b;
while( *bp = *inname ) {
++bp;
++inname;
}
action=action;
if( DosOpen( b, &hdl, &action, 0L, 0, 1, 0x10 ,0L ) == 0 ) {
DosChgFilePtr( hdl, 0L, 2, &ppos );
pos = ppos;
DosChgFilePtr( hdl, 0L, 0, &ppos );
#ifdef DOS
{
static int alias_seg;
DosAllocSeg( pos + 1 + ALIAS_SLACK, &alias_seg, 0 );
*(((int far *)&AliasList)+0) = 0;
*(((int far *)&AliasList)+1) = alias_seg;
AliasSize = pos + ALIAS_SLACK;
}
#else
AliasList = AliasArea;
AliasSize = 2047;
#endif
DosRead( hdl, AliasList, pos, &read );
if( pos > 0 && AliasList[ pos-1 ] != '\n' ) {
AliasList[ pos+0 ] = '\r';
AliasList[ pos+1 ] = '\n';
AliasList[ pos+2 ] = '\0';
} else {
AliasList[ pos ] = '\0';
}
DosClose( hdl );
} else {
AliasList = &noalias;
}
return( endname );
}