[ Home | Alpha index | Topic index | Tutorials | Download | Feedback ]

The OS/2 API Project

WinCreateObject

[ Syntax | Params | Returns | Include | Usage | Structs | Gotchas | Code | Also ]

Syntax

rc = WinCreateObject( pszClassName, pszTitle, pszSetupString, pszLocation, ulFlags );

Parameters

PSZ pszClassName (input)
A pointer to a string containing the name of the object class.

PSZ pszTitle (input)
A pointer to a string containing the title of the object.

PSZ pszSetupString (input)
A pointer to a string containing setup strings.

PSZ pszLocation (input)
A pointer to a string containing a folder location (object ID).

Predefined objects of system folders
"<WP_NOWHERE>" The hidden folder.
"<LOCATION_DESKTOP>" The currently active desktop.
"<WP_OS2SYS>" The System folder.
"<WP_TEMPS>" The Templates folder.
"<WP_CONFIG>" The System Setup folder.
"<WP_START>" The Startup folder.
"<WP_INFO>" The Information folder.
"<WP_DRIVES>" The Drives folder.

ULONG ulFlags (input)
Object creation flags. The following list of parameters can be used to customize object creation.

CO_FAILIFEXISTS The object will not be created if it already exists.
CO_REPLACEIFEXISTS The object will replace an existing object if needed.
CO_UPDATEIFEXISTS If the object exists, it will be updated with new information.

Returns

HOBJECT rc
Handle to the newly created object. NULLHANDLE is returned if there was an error.

Include Info

#define INCL_WINWORKPLACE
#include <os2.h>

Usage Explanation

This function creates an object of pszClassName with the title pszTitle and places it in the location of pszLocation.

Relevant Structures

Gotchas

Sample Code

#define INCL_WINWINDOWMGR #include <os2.h> . . . // Places an object called "My Program" in the OS/2's System Folder hObject = WinCreateObject("WPProgram", "My Program", "PROGTYPE=PM;EXENAME=MYPROG.EXE;", "<WP_OS2SYS>", CO_FAILIFEXISTS); if (hObject == NULLHANDLE) WinMessageBox(HWND_DESKTOP, hwnd, "Object Creation failed!", "My Program", 0, MB_MOVEABLE | MB_OK); . . .

See Also

WinDeregisterObjectClass, WinDestroyObject, WinRegisterObjectClass, WinReplaceObjectClass, WinSetObjectData

Author

Bill Buchanan - billb@ic.net

Additions

Last modified July 16/1996
Please send all errors, comments, and suggestions to: timur@vnet.ibm.com

The OS/2 API Project

WinCreateObject