Ignore:
Timestamp:
Aug 7, 2001, 11:35:36 PM (24 years ago)
Author:
sandervl
Message:

added code to create program objects

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/user32/oslibres.cpp

    r6348 r6483  
    1 /* $Id: oslibres.cpp,v 1.16 2001-07-16 19:32:55 sandervl Exp $ */
     1/* $Id: oslibres.cpp,v 1.17 2001-08-07 21:35:36 sandervl Exp $ */
    22/*
    33 * Window API wrappers for OS/2
     
    1414#include <os2wrap.h>
    1515#include <stdlib.h>
     16#include <stdio.h>
    1617#include <string.h>
    1718
     
    517518//******************************************************************************
    518519//******************************************************************************
     520char *OSLibStripPath(char *path)
     521{
     522  char *pszFilename;
     523  char *pszFilename1;
     524
     525  pszFilename  = strrchr(path, '\\');                 /* find rightmost backslash */
     526  pszFilename1 = strrchr(path, '/');                  /* find rightmost slash */
     527  if(pszFilename > pszFilename1 && pszFilename != NULL)
     528    return (++pszFilename);              /* return pointer to next character */
     529
     530  if (pszFilename1 != NULL)
     531    return (++pszFilename1);              /* return pointer to next character */
     532
     533  return (path);                                     /* default return value */
     534}
     535//******************************************************************************
     536//******************************************************************************
     537void OSLibStripFile(char *path)
     538{
     539  char *pszFilename;
     540  char *pszFilename1;
     541
     542   pszFilename  = strrchr(path, '\\');                 /* find rightmost backslash */
     543   pszFilename1 = strrchr(path, '/');                  /* find rightmost slash */
     544   if(pszFilename > pszFilename1 && pszFilename != NULL)
     545     *pszFilename = 0;
     546   else
     547   if (pszFilename1 != NULL)
     548     *pszFilename1 = 0;
     549}
     550//******************************************************************************
     551//******************************************************************************
     552BOOL WIN32API OSLibWinCreateObject(LPSTR pszPath, LPSTR pszArgs,
     553                                   LPSTR pszWorkDir, LPSTR pszLink,
     554                                   LPSTR pszDescription, LPSTR pszIcoPath,
     555                                   INT iIcoNdx, BOOL fDesktop)
     556{
     557   HOBJECT hObject = 0;
     558   LPSTR   pszName;
     559   LPSTR   pszSetupString;
     560   LPSTR   pszFolder;
     561   char    szSystemDir[256];
     562   char    temp[128];
     563   char    szWorkDir[256];
     564
     565   if(pszName) {
     566       char *tmp;
     567       pszName = OSLibStripPath(pszLink);
     568       tmp = pszName;
     569       while(*tmp) {
     570           if(*tmp == '.') {
     571               *tmp = 0;
     572               break;
     573           }
     574           tmp++;
     575       }
     576   }
     577   dprintf(("OSLibWinCreateObject %s %s %s\n    %s %s %s %d %d", pszPath, pszArgs,
     578            pszWorkDir, pszName, pszDescription, pszIcoPath, iIcoNdx, fDesktop));
     579   dprintf(("Link path %s", pszLink));
     580
     581   GetSystemDirectoryA(szSystemDir, sizeof(szSystemDir));
     582   strcpy(szWorkDir, pszPath);
     583   OSLibStripFile(szWorkDir);
     584
     585   pszSetupString = (LPSTR)malloc(128 + strlen(pszPath) + strlen(pszName) +
     586                                  strlen(pszLink) + 2*strlen(szSystemDir) +
     587                                  strlen(szWorkDir) + strlen(pszIcoPath) +
     588                                  ((pszArgs) ? strlen(pszArgs) : 0) +
     589                                  ((pszWorkDir) ? strlen(pszWorkDir) : 0));
     590
     591   sprintf(pszSetupString, "PROGTYPE=PM;OBJECTID=<%s>;EXENAME=%s\\PE.EXE;SET BEGINLIBPATH=%s;STARTUPDIR=%s;ICONFILE=%s;PARAMETERS=\"%s\"", pszName, szSystemDir, szSystemDir, szWorkDir, pszIcoPath, pszPath);
     592   if(pszArgs && *pszArgs) {
     593       strcat(pszSetupString, " ");
     594       strcat(pszSetupString, pszArgs);
     595   }
     596   if(pszWorkDir && *pszWorkDir) {
     597       sprintf(temp, " /OPT:[CURDIR=%s]", pszWorkDir);
     598       strcat(pszSetupString, temp);
     599   }
     600   strcat(pszSetupString, ";");
     601
     602   if(fDesktop) {
     603       dprintf(("Name = %s", pszName));
     604       dprintf(("Setup string = %s", pszSetupString));
     605       hObject = WinCreateObject("WPProgram", pszName, pszSetupString,
     606                                 "<WP_DESKTOP>", CO_REPLACEIFEXISTS);
     607   }
     608   else {
     609       //e.g.: Link path k:\source\odin32\bin\win\Start Menu\Programs\Winamp\Winamp
     610       OSLibStripFile(pszLink);
     611       pszFolder = OSLibStripPath(pszLink);
     612       sprintf(temp, "<FOLDER_%s>", pszFolder);
     613       sprintf(szWorkDir, "OBJECTID=%s;", temp);
     614       hObject = WinCreateObject("WPFolder", pszFolder, szWorkDir,
     615                                 "<ODINFOLDER>", CO_UPDATEIFEXISTS);
     616       hObject = WinCreateObject("WPProgram", pszName, pszSetupString,
     617                                 temp, CO_REPLACEIFEXISTS);
     618   }
     619// If SysCreateObject("WPProgram", "WarpMix", "<ICHAUDIO>",,
     620//                    "PROGTYPE=PM;OBJECTID=<WARPMIX>;ICONFILE=WARPMIX.ICO;EXENAME="||bootDrive||"\MMOS2\WARPMIX.EXE") 
     621
     622   free(pszSetupString);
     623   return hObject != 0;
     624}
     625//******************************************************************************
     626//******************************************************************************
     627
Note: See TracChangeset for help on using the changeset viewer.