home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
wpsgpf.zip
/
TRYSIM.C
< prev
next >
Wrap
Text File
|
1995-02-22
|
3KB
|
90 lines
#define INCL_DOSERRORS
#define INCL_WINERRORS
#define INCL_WINWINDOWMGR
#define INCL_WINWORKPLACE
#include <os2.h>
#include <stdio.h>
#include <string.h>
#define LOCATION "<WP_DESKTOP>"
#define CLASSNAME "WPSimple"
#define OBJECTNAME "My"
#define DLLNAME "sim"
/* #define SETUP NULL*/
#define SETUP "ICONNUMBER=3"
/*===========================================================================*/
VOID Use (VOID) {
printf ("use: tryit [/d | /r | /c]\n");
printf ("where: /d is deregister only\n");
printf (" /r is register only\n");
printf (" /c is create only\n");
exit (-1);
}
#define TODO_DEREGISTER 0x0001
#define TODO_REGISTER 0x0002
#define TODO_CREATE 0x0004
/*===========================================================================*/
int main(int argc, char **argv)
{
HAB hab;
BOOL fToDo = 0x0000;
ERRORID errid;
hab = WinQueryAnchorBlock (HWND_DESKTOP);
if (1 == argc) {
fToDo = TODO_DEREGISTER | TODO_REGISTER | TODO_CREATE;
} else if (2 == argc) {
if (strcmp (argv [1], "/d") == 0) {
fToDo |= TODO_DEREGISTER;
} else if (strcmp (argv [1], "/r") == 0) {
fToDo |= TODO_REGISTER;
} else if (strcmp (argv [1], "/c") == 0) {
fToDo |= TODO_CREATE;
} else if (strcmp (argv [1], "/?") == 0) {
Use ();
} else {
Use ();
}
} else {
Use ();
}
/*-----------------------------------------------------------------------*/
if (fToDo & TODO_DEREGISTER) {
if (WinDeregisterObjectClass(CLASSNAME)) {
printf("Deregister %s OK\n", CLASSNAME);
} else {
printf("Failed to deregister %s (Err: %lx)\n",
CLASSNAME, WinGetLastError (hab));
}
}
/*-----------------------------------------------------------------------*/
if (fToDo & TODO_REGISTER) {
if (WinRegisterObjectClass(CLASSNAME, DLLNAME)) {
printf("Register %s (%s) OK\n", CLASSNAME, DLLNAME);
} else {
printf("Failed to register %s (%s) (Err: %lx)\n",
CLASSNAME, DLLNAME, WinGetLastError (hab));
}
}
/*-----------------------------------------------------------------------*/
if (fToDo & TODO_CREATE) {
if (WinCreateObject(CLASSNAME, OBJECTNAME, SETUP, LOCATION,
CO_REPLACEIFEXISTS )) {
printf("Object %s of class %s created in %s\n",
OBJECTNAME, CLASSNAME, LOCATION);
} else {
printf("Failed to create %s of class %s (Err: %lx)\n",
OBJECTNAME, CLASSNAME, WinGetLastError (hab));
}
}
return 0;
}