home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
High Voltage Shareware
/
high1.zip
/
high1
/
DIR2
/
DCOPYPM5.ZIP
/
SUPPDEL.C
< prev
next >
Wrap
Text File
|
1993-11-30
|
5KB
|
153 lines
#define INCL_DOS
#define INCL_WIN
#define INCL_WINDIALOGS
#define INCL_DOSPROCESS
#define INCL_DOSSESMGR /* Session Manager values */
#define LEN_BUFFER 512
#include <os2.h>
#include <stdio.h>
#include <string.h>
#include "suppdel.h"
static char error[LEN_BUFFER]="";
APIRET undelete(HWND hwndDlg,char *pgm,char *para)
{
STARTDATA StartData;
STATUSDATA StatusData;
ULONG SessID,AppType;
RESULTCODES ReturnCodes;
PID RetProcessID,PID;
UCHAR PgmTitle[LEN_BUFFER];
UCHAR ObjBuf[100];
APIRET rc;
CHAR *ret,count;
// OS2-Sessions starten
StartData.PgmName = pgm;
StartData.SessionType = SSF_TYPE_DEFAULT;
StartData.PgmInputs = para;
StartData.Length = sizeof(STARTDATA);
StartData.Related = SSF_RELATED_CHILD;
StartData.FgBg = SSF_FGBG_FORE;
StartData.TraceOpt = SSF_TRACEOPT_NONE;
StartData.PgmTitle = 0;
StartData.TermQ = 0;
StartData.Environment = 0;
StartData.InheritOpt = SSF_INHERTOPT_PARENT;
StartData.IconFile = 0;
StartData.PgmHandle = 0;
StartData.PgmControl = SSF_CONTROL_INVISIBLE;
StartData.InitXPos = 0;
StartData.InitYPos = 0;
StartData.InitXSize = 0;
StartData.InitYSize = 0;
StartData.Reserved = 0;
StartData.ObjectBuffer = ObjBuf;
StartData.ObjectBuffLen = 100;
rc = DosStartSession(&StartData, &SessID, &PID);
DosSleep(500);
StatusData.Length=sizeof(STATUSDATA);
StatusData.SelectInd=SET_SESSION_UNCHANGED;
StatusData.BondInd=SET_SESSION_UNCHANGED;
while(!DosSetSession(SessID,&StatusData))DosSleep(500);
return(0);
}
MRESULT EXPENTRY MyDlgProc( HWND hwndDlg, USHORT msg, MPARAM mp1, MPARAM mp2 )
{
char buffer[LEN_BUFFER],list[LEN_BUFFER],*token;
FILE *del_file;
APIRET rc;
SHORT tst,count=0,num;
switch ( msg )
{
case WM_INITDLG:
WinSendMsg(hwndDlg,WM_SETICON,(MPARAM)WinLoadPointer(HWND_DESKTOP, 0, IDR_MAIN),0);
undelete(hwndDlg,"CMD.EXE","/c UNDELETE.COM /l /s \\* >C:\\DCOPY.!!!");
del_file=fopen("C:\\DCOPY.!!!","r");
while(fgets(buffer,LEN_BUFFER,del_file))
{
if(++count <= 2)
{
if(*buffer!='\n' && count==2)
{
strcpy(error,strtok(buffer,"\n"));
while(fgets(buffer,LEN_BUFFER,del_file))
{
strcat(error," ");
token=strtok(buffer,"\n");
strcat(error,(token)?token:"");
}
WinDismissDlg(hwndDlg,FALSE);
break;
}
else continue;
}
if(token=strtok(buffer,"\n"))
if((tst=SHORT1FROMMP(WinSendDlgItemMsg(hwndDlg, LIST_UNDELETE, LM_SEARCHSTRING, MPFROM2SHORT(0, -1), MPFROMP(token))))==LIT_NONE)
WinSendDlgItemMsg(hwndDlg, LIST_UNDELETE, LM_INSERTITEM, MPFROM2SHORT(LIT_SORTASCENDING, 0),MPFROMP(token));
}
fclose(del_file);
DosDelete("C:\\DCOPY.!!!");
break;
case WM_COMMAND: /* Posted by pushbutton or key */
switch( SHORT1FROMMP( mp1 ) ) /* Extract the command value */
{
case BUT_UNDELETE:
if((num=SHORT1FROMMP(WinSendDlgItemMsg(hwndDlg, LIST_UNDELETE, LM_QUERYSELECTION, MPFROM2SHORT(-1, 0), 0)))!=LIT_NONE)
do
{
WinSendDlgItemMsg(hwndDlg, LIST_UNDELETE, LM_QUERYITEMTEXT, MPFROM2SHORT(num, LEN_BUFFER), MPFROMP(buffer));
// existiert File schon ?
if(del_file=fopen(buffer,"r")){ fclose(del_file); continue; }
strcpy(list, "/c DETACH UNDELETE.COM ");
strcat(list,buffer);
strcat(list," /A");
if(undelete(hwndDlg,"CMD.EXE",list))
WinMessageBox(hwndDlg,0,buffer,"Error while undeleting:",1, MB_OK|MB_ICONEXCLAMATION|MB_SYSTEMMODAL);
}while((num=SHORT1FROMMP(WinSendDlgItemMsg(hwndDlg, LIST_UNDELETE, LM_QUERYSELECTION, MPFROM2SHORT(num, 0), 0)))!=LIT_NONE);
WinDismissDlg(hwndDlg,TRUE);
break;
case BUT_CANCEL:
WinDismissDlg(hwndDlg,TRUE);
break;
case BUT_HELP:
undelete(hwndDlg,"CMD.EXE","/c help undelete");
break;
}
break;
default:
return WinDefDlgProc( hwndDlg, msg, mp1, mp2 );
}
return (MRESULT) FALSE;
}
APIRET Supp_Undel(HMODULE hmodule,HWND hwndDlg, char *para, void *fkt[])
{
APIRET rc;
HMODULE ModuleHandle;
ULONG Ordinal; /* Ordinal number of procedure */
PFN ProcAddress; /* Procedure address (returned) */
if(!(rc=WinDlgBox( hwndDlg,hwndDlg,(PFNWP)MyDlgProc,hmodule,UNDEL_DLG,NULL)))
WinMessageBox(hwndDlg,0,error,NULL,1, MB_OK|MB_ICONEXCLAMATION|MB_SYSTEMMODAL);
return(0);
}