コード例 #1
0
void RecallWindowSizePos(void)
{
    int deskw,deskh;
    GetDefaultWH(deskw,deskh);
    char ws[32+1];
    char hs[32+1];
    sprintf(ws,"%d",deskw);
    sprintf(hs,"%d",deskh);
    ///
    char path[400+1];
    sprintf(path,"%s\\PROFOWL.INI",MyHomePath);
    HAB hab;
    HINI  hini = PrfOpenProfile(hab,path);
    char s[MAXPATHSIZE];
    s[0] = NULL;
    PrfQueryProfileString(hini,"profsowl","X","16",s,32);
    int x = atoi(s);
    PrfQueryProfileString(hini,"profsowl","Y","3",s,32);
    int y = atoi(s);
    PrfQueryProfileString(hini,"profsowl","Width",ws,s,32);
    int w = atoi(s);
    PrfQueryProfileString(hini,"profsowl","Height",hs,s,32);
    int h = atoi(s);
    PrfCloseProfile(hini);
    //
    // IF Something Valid To Recall !
    //
    if(x >= 0 && x < 1000 && y >= 0 && y < 1000)
    {
        MainFramePtr->MoveWindow(x,y,w,h,TRUE);
    }
}
コード例 #2
0
ファイル: serialt.c プロジェクト: OS2World/APP-COMM-ComScope
BOOL CopyProfile(HINI hSourceProfile,HINI hDestinationProfile)
{
    int iAppIndex;
    int iKeyIndex;
    char *pKeyNames;
    char *pAppNames;
    char *pAppName;
    char *pKeyName;
    ULONG ulAppSize;
    ULONG ulDataSize;
    ULONG ulKeySize;
    void *pData;

    PrfQueryProfileSize(hSourceProfile,0L,0L,&ulAppSize);
    if ((pAppNames = malloc(ulAppSize + 1)) == NULL)
        return(FALSE);
    PrfQueryProfileString(hSourceProfile,0L,0L,0L,pAppNames,ulAppSize);
    iAppIndex = 0;
    while (iAppIndex < ulAppSize)
    {
        pAppName = &pAppNames[iAppIndex];
        PrfQueryProfileSize(hSourceProfile,pAppName,0L,&ulKeySize);
        if ((pKeyNames = malloc(ulKeySize + 1)) == NULL)
        {
            free (pAppNames);
            return(FALSE);
        }
        PrfQueryProfileString(hSourceProfile,pAppName,0L,0L,pKeyNames,ulKeySize);
        iKeyIndex = 0;
        while (iKeyIndex < ulKeySize)
        {
            pKeyName = &pKeyNames[iKeyIndex];
            PrfQueryProfileSize(hSourceProfile,pAppName,pKeyName,&ulDataSize);
            if ((pData = malloc(ulDataSize + 1)) != NULL)
            {
                PrfQueryProfileData(hSourceProfile,pAppName,pKeyName,pData,&ulDataSize);
                PrfWriteProfileData(hDestinationProfile,pAppName,pKeyName,pData,ulDataSize);
                free(pData);
            }
            while(pKeyNames[iKeyIndex++] != 0);
            if (pKeyNames[iKeyIndex] == 0)
                break;;
        }
        free(pKeyNames);
        while(pAppNames[iAppIndex++] != 0);
        if (pAppNames[iAppIndex] == 0)
            break;;
    }
    free(pAppNames);
    return(TRUE);
}
コード例 #3
0
// try loading each plugin module.
// if opened sucessfully, call the plugin's CBZParseAttributes(hIni, keyValue, count) function
// the plugin is responsible for writing data to the ini file.
BOOL ApplyPreviewTheme(HWND hwndPreview, char themeFile[])
{
    HINI hIni;
    int count = 0;
    char szProfile[CCHMAXPATH + 1];
    char szPluginBase[CCHMAXPATH];

    // get profile name
    if (!PrfQueryProfileString(HINI_USERPROFILE,
                               "CandyBarZ",
                               "Profile",
                               NULL,
                               szProfile,
                               CCHMAXPATH))
    {
        PSUTErrorFunc(NULLHANDLE, "Error", "ApplyPreviewTheme", "Failed to Get Profile Filename", 0UL);
        return FALSE;
    }

    // get profile name
    if (!PrfQueryProfileString(HINI_USERPROFILE,
                               "CandyBarZ",
                               "BasePath",
                               NULL,
                               szPluginBase,
                               CCHMAXPATH))
    {
        PSUTErrorFunc(NULLHANDLE, "Error", "ApplyPreviewTheme", "Failed to Get BasePath", 0UL);
        return FALSE;
    }


    if ((hIni = PrfOpenProfile(WinQueryAnchorBlock(hwndPreview), szProfile)) == NULLHANDLE)
    {
        PSUTErrorFunc(NULLHANDLE, "Error", "ApplyPreviewTheme", "Failed to Open Profile", 0UL);
        return FALSE;
    }

    count = ApplyPreviewBlock(hwndPreview, themeFile, "TITLEBAR", szPluginBase, hIni, 0);
    count = ApplyPreviewBlock(hwndPreview, themeFile, "FRAME", szPluginBase, hIni, count);
    count = ApplyPreviewBlock(hwndPreview, themeFile, "FRAMEBRDR", szPluginBase, hIni, count);
    count = ApplyPreviewBlock(hwndPreview, themeFile, "PUSHBUTTON", szPluginBase, hIni, count);
    count = ApplyPreviewBlock(hwndPreview, themeFile, "RADIOBUTTON", szPluginBase, hIni, count);
    count = ApplyPreviewBlock(hwndPreview, themeFile, "CHECKBOX", szPluginBase, hIni, count);
    count = ApplyPreviewBlock(hwndPreview, themeFile, "MINMAX", szPluginBase, hIni, count);
    count = ApplyPreviewBlock(hwndPreview, themeFile, "MENU", szPluginBase, hIni, count);
    //insert here!!!!
    PrfCloseProfile(hIni);
    return TRUE;
}
コード例 #4
0
static void detectBrowser( void )
{
    char *prfApp = "WPURLDEFAULTSETTINGS";

    if ( strcmp( browserExe, "" ) == 0 )
    {
        PrfQueryProfileString( HINI_USER, prfApp, "DefaultBrowserExe", "",
                               browserExe, CCHMAXPATH );
        PrfQueryProfileString( HINI_USER, prfApp, "DefaultWorkingDir", "",
                               browserDir, CCHMAXPATH );
    }

    if ( strcmp( browserExe, "" ) == 0 )
    {
        APIRET rc;
        rc = DosSearchPath( SEARCH_CUR_DIRECTORY | SEARCH_ENVIRONMENT | SEARCH_IGNORENETERRS ,
                            "PATH", "NETSCAPE.EXE", browserExe, CCHMAXPATH );
        if ( rc != 0 )  strcpy( browserExe , "" );
    }
}
コード例 #5
0
ファイル: gvpmisc.c プロジェクト: 131/gsview
void
play_system_sound(char *id)
{
HINI hini;
char buf[MAXSTR];
char *p;
	if ( (hini = PrfOpenProfile(hab, szMMini)) == NULLHANDLE )
	    return;
	PrfQueryProfileString(hini, (PCSZ)"MMPM2_AlarmSounds", (PCSZ)id, (PCSZ)"##", buf, sizeof(buf));
	PrfCloseProfile(hini);
    	p = strchr(buf,'#');
    	if (p != (char *)NULL) {
	    *p = '\0';
	    (*pfnMciPlayFile)(hwnd_frame, (PSZ)buf, 0, 0, 0);
	}
	return;
}
コード例 #6
0
ファイル: profile-old.cpp プロジェクト: kidaa/BermudaTriangle
/*************************************************************************\
 * function ReadProfile()
 * Tries to open the file "bermuda.ini" and sets game specific options taken
 * from the profile data. If the file isn't found or the data is invalid
 * FALSE is returned otherwise the function returns TRUE.
\*************************************************************************/
BOOL ReadProfile( HAB hab )
{
	CHAR pszVersionFound[MaxVersionLen] = "";
	ULONG lNumRead;
	ULONG tmpLineStyle;
	BOOL  tmpSound;
	HINI hini;
	PSZ pszIniNameCopy;


	pszIniNameCopy = (PSZ)alloca( strlen( pszIniName ) + 1);
	strcpy( pszIniNameCopy, pszIniName );
	if ( !(hini = PrfOpenProfile( hab, pszIniNameCopy )) ) goto Error;

	// query version string
	PrfQueryProfileString( hini, pszAppName, PrfKeys.pszVersion, NULL,
								  pszVersionFound, MaxVersionLen );
	// and compare with current version								  
	if ( strcmp( pszVersion, pszVersionFound ) != 0 ){
		PrfCloseProfile( hini );
		return FALSE;
	}

	// retrieve line style settings
	lNumRead = sizeof( ULONG );
	if( !PrfQueryProfileData( hini, pszAppName, PrfKeys.pszLineStyle,
		 &tmpLineStyle, &lNumRead ) ) goto Error;
	InfoData.SetLineStyle( tmpLineStyle );		 
	// retrieve sound flag
	lNumRead = sizeof( BOOL );
	if( !PrfQueryProfileData( hini, pszAppName, PrfKeys.pszSound,
		 &tmpSound, &lNumRead ) )
		 goto Error;
	Sound::SetSoundWanted( tmpSound );		 

	if ( !RestoreWindowPos( hini, pszAppName, PrfKeys.pszWinPos, hwndFrame )
		) goto Error;
	PrfCloseProfile( hini );
	return TRUE;

Error:
	PrfCloseProfile( hini );
	return FALSE;
}
コード例 #7
0
int GetInstallDir(char * installDir, int size)
{

  *installDir=0;

  // query location of candybarz profile
  if (!PrfQueryProfileString(HINI_USERPROFILE,
                             "CandyBarZ",
                             "BasePath",
                             NULL,
                             installDir,
                             size))
    {
      return (0);
    }

  return 1;  

}
コード例 #8
0
void RecallProjectPath(char *rs, int ChDir)
{
    char path[400+1];
    sprintf(path,"%s\\PROFOWL.INI",MyHomePath);
    HAB hab;
    HINI  hini = PrfOpenProfile(hab,path);
    char s[MAXPATHSIZE];
    PrfQueryProfileString(hini,"profsowl","ProjectPath",".\\",s,sizeof(s));
    PrfCloseProfile(hini);

    if(ChDir && s[1] == ':')
    {
        ChPath(s);
    }

    if(rs)
    {
        strcpy(rs,s);
    }
}
コード例 #9
0
// InitPlugins(hwnd, pTBData, appName, hwndLBSelected,
//                   hwndLBAvailable, hwndLBAvailableDLL )
//    hwnd     --> Handle of the calling window
//    pTBData  --> Pointer to the titlebar's CandyBarZ data structure
//    hwndLBSelected       --> Handle of the ListBox containing the Selected Plugin Names
//    hwndLBAvailable      --> Handle of the ListBox containing the Available Plugin Names
//    hwndLBAvailableDLL   --> Handle of the ListBox containing the Available Plugin DLL Names
//    bActive  --> which array to load into. (active or inactive)
BOOL InitPlugins(HWND hwnd, CBZDATA *pCBZData, char appName[], HWND hwndLBSelected,
                 HWND hwndLBAvailable, HWND hwndLBAvailableDLL)
{
    int i, index, count;
    char szBase[CCHMAXPATH], szFile[CCHMAXPATH];
    char szError[32];
    PLUGINPFN pPluginInfoFunction;
    PLUGIN_INFO pluginInfo;
    PINITFN pInitFn;

    //Query the path to the Plugin directory
    PrfQueryProfileString(HINI_USERPROFILE,
                          "CandyBarZ",
                          "BasePath",
                          NULL,
                          szBase,
                          CCHMAXPATH);
    strcat(szBase, "plugins");

    count = pCBZData->cbPlugins;

    //initialize each plugin
    for (i = 0; i < count; i++)
    {
        //Initialize to some initial values...
        pCBZData->Plugins[i].bActiveEnabled = TRUE;
        pCBZData->Plugins[i].bInactiveEnabled = TRUE;
        pCBZData->Plugins[i].pData = NULL;
        pCBZData->Plugins[i].cbData = 0;

        //Load the Plugin Module
        _makepath(szFile, NULL, szBase, pCBZData->Plugins[i].szPluginDLL, "DLL");
        if (DosLoadModule(szError, sizeof(szError), szFile,
                          &(pCBZData->Plugins[i].hModDll)) != NO_ERROR)
        {
            //Error loading the dll...disable this plugin!
            pCBZData->Plugins[i].bActiveEnabled = FALSE;
            pCBZData->Plugins[i].bInactiveEnabled = FALSE;
            continue;           //end this iteration...try next plugin.

        }

        //Query the Plugin's Window Procedure.
        if (DosQueryProcAddr(pCBZData->Plugins[i].hModDll, 0, "CBZPluginWndProc",
                             (PFN *) & (pCBZData->Plugins[i].pPluginWndProc)) != NO_ERROR)
        {
            //error getting the Plugin's WndProc...disable the plugin!
            pCBZData->Plugins[i].bActiveEnabled = FALSE;
            pCBZData->Plugins[i].bInactiveEnabled = FALSE;
            DosFreeModule(pCBZData->Plugins[i].hModDll);
            continue;           //end this iteration...try next plugin.

        }

        //Query The Plugin's CBZInit Function
        if (DosQueryProcAddr(pCBZData->Plugins[i].hModDll, 0, "CBZInit",
                             (PFN *) & (pInitFn)) != NO_ERROR)
        {
            PSUTErrorFunc(hwnd,
                          "Error",
                          "AddPlugin",
                          "Error Quering CBZInit!",
                          0UL);
            //error in Plugin's initialization...disable the plugin!
            pCBZData->Plugins[i].bActiveEnabled = FALSE;
            pCBZData->Plugins[i].bInactiveEnabled = FALSE;
            DosFreeModule(pCBZData->Plugins[i].hModDll);
            return (FALSE);
        }
        //Call the plugins Init function.
        if (!pInitFn(NULLHANDLE, "", "TITLEBAR", (PVOID *) & (pCBZData->Plugins[i].pData)))
        {
            PSUTErrorFunc(hwnd,
                          "Error",
                          "AddPlugin",
                          "Error running the plugin's CBZInit function!",
                          0UL);
            //error in Plugin's initialization...disable the plugin!
            pCBZData->Plugins[i].bActiveEnabled = FALSE;
            pCBZData->Plugins[i].bInactiveEnabled = FALSE;
            DosFreeModule(pCBZData->Plugins[i].hModDll);
            return (FALSE);
        }

        //Query the address of the plugin's Render function.
        if (DosQueryProcAddr(pCBZData->Plugins[i].hModDll, 0, "CBZPluginRender",
                             (PFN *) & (pCBZData->Plugins[i].pfnPluginRender)) != NO_ERROR)
        {
            //Error getting CBZPluginRender function!
            pCBZData->Plugins[i].bActiveEnabled = FALSE;
            pCBZData->Plugins[i].bInactiveEnabled = FALSE;
            DosFreeModule(pCBZData->Plugins[i].hModDll);
            DosFreeMem(pCBZData->Plugins[i].pData);

            continue;           //end this iteration...try next plugin.

        }

        if (DosQueryProcAddr(pCBZData->Plugins[i].hModDll, 0, "CBZPluginInfo",
                             (PFN *) & (pPluginInfoFunction)) != NO_ERROR)
        {
            //Error getting CBZPluginInfo function!
            pCBZData->Plugins[i].bActiveEnabled = FALSE;
            pCBZData->Plugins[i].bInactiveEnabled = FALSE;
            DosFreeModule(pCBZData->Plugins[i].hModDll);
            DosFreeMem(pCBZData->Plugins[i].pData);
            continue;           //end this iteration...try next plugin

        }

        //query the plugin's info structure
        pPluginInfoFunction(&pluginInfo);

        //Add this plugin to the SelectedPlugins ListBox
        WinSendMsg(hwndLBSelected, LM_INSERTITEM,
                   MPFROMSHORT((SHORT) LIT_END),
                   MPFROMP(pluginInfo.PluginName));

        //Determine the index of the corresponding entry in the AvailablePluginDLLS ListBox
        index = (SHORT) WinSendMsg(hwndLBAvailableDLL, LM_SEARCHSTRING,
                                   MPFROM2SHORT(LSS_CASESENSITIVE, LIT_FIRST),
                                   MPFROMP(pCBZData->Plugins[i].szPluginDLL));
        if (index != LIT_ERROR && index != LIT_NONE)
        {
            //Remove the entry from the AvailablePlugin... ListBoxes so we can only select
            // each plugin once.
            WinSendMsg(hwndLBAvailableDLL, LM_DELETEITEM,
                       MPFROMSHORT((SHORT) index),
                       MPFROMLONG(0));
            WinSendMsg(hwndLBAvailable, LM_DELETEITEM,
                       MPFROMSHORT((SHORT) index),
                       MPFROMLONG(0));
        }
    }                           //end for(..) loop

    return (TRUE);              //plugins initialized sucessfully!

}
コード例 #10
0
// LoadPlugins(hwnd, pTBData, hwndLBAvailable, hwndLBAvailableDLL, bActive)
//    hwnd     --> Handle of the calling window
//    pTBData  --> Pointer to the titlebar's CandyBarZ data structure
//    hwndLBAvailable      --> Handle of the ListBox containing the Available Plugin Names
//    hwndLBAvailableDLL   --> Handle of the ListBox containing the Available Plugin DLL Names
BOOL LoadPlugins(HWND hwnd, CBZDATA * pCBZData, HWND hwndLBAvailable, HWND hwndLBAvailableDLL, long Win_Type)
{
    HMODULE hModPlug;

    int index;
    char dllName[9];

    char szError[32];
    PLUGINPFN pPluginInfoFunction;
    PLUGIN_INFO pluginInfo;

    HDIR hdirFindHandle = HDIR_CREATE;
    FILEFINDBUF3 FindBuffer = {0};
    ULONG ulResultBufLen = sizeof(FILEFINDBUF3);
    ULONG ulFindCount = 1;
    APIRET rc = NO_ERROR;

    char szBase[CCHMAXPATH], szFile[CCHMAXPATH];

    //Query the BasePath to the CandyBarZ Plugins
    PrfQueryProfileString(HINI_USERPROFILE,
                          "CandyBarZ",
                          "BasePath",
                          NULL,
                          szBase,
                          CCHMAXPATH);

    strcpy(szFile, szBase);
    strcat(szFile, "plugins\\*.dll");  //Wildcard for searching available plugins

    strcat(szBase, "plugins");  //used for completing full path to plugins

    // Querying all the Plugin DLL's in the %candybarz%\plugins directory.
    if ((rc = DosFindFirst(szFile,
                           &hdirFindHandle,
                           FILE_NORMAL,
                           &FindBuffer,
                           ulResultBufLen,
                           &ulFindCount,
                           FIL_STANDARD)) != NO_ERROR)
    {
        PSUTErrorFunc(hwnd, "Error", "LoadPlugins", "Failed to get Available Plugins", 0UL);
        return (FALSE);
    }
    else
    {
        //construct the full path the to the plugin
        _splitpath(FindBuffer.achName, NULL, NULL, dllName, NULL);
        strupr(dllName);
        _makepath(szFile, NULL, szBase, dllName, "DLL");

        if (DosLoadModule(szError, sizeof(szError), szFile, &hModPlug) == NO_ERROR)
        {
            //Load the CBZPluginInfo function so we can Query the plugin's Information
            if (DosQueryProcAddr(hModPlug, 0, "CBZPluginInfo", (PFN *) & (pPluginInfoFunction)) == NO_ERROR)
            {
                //Query the PLUGIN_INFO struct from the plugin referenced by hModPlug
                pPluginInfoFunction(&pluginInfo);
                if (pluginInfo.lWindowTypes & Win_Type)
                {
                    //Add the Plugin's Name to the AvailablePlugins ListBox.
                    index = (SHORT) WinSendMsg(hwndLBAvailable, LM_INSERTITEM,
                                               MPFROMSHORT((SHORT) LIT_SORTASCENDING),
                                               MPFROMP(pluginInfo.PluginName));

                    //Add the Plugin's DLL Name to the offscreen AvailablePluginDLLs ListBox.
                    // keeping it synchronized with the AvailablePlugins ListBox
                    WinSendMsg(hwndLBAvailableDLL, LM_INSERTITEM,
                               MPFROMSHORT((SHORT) index),
                               MPFROMP(dllName));
                }
            }
            DosFreeModule(hModPlug);
        }

        //keep looping until all the available plugins have be found
        while (rc != ERROR_NO_MORE_FILES)
        {
            ulFindCount = 1;

            //Get the next Plugin DLL
            rc = DosFindNext(hdirFindHandle, &FindBuffer, ulResultBufLen, &ulFindCount);
            if ((rc != ERROR_NO_MORE_FILES))
            {
                //construct the full path the to the plugin
                _splitpath(FindBuffer.achName, NULL, NULL, dllName, NULL);
                strupr(dllName);
                _makepath(szFile, NULL, szBase, dllName, "DLL");

                if (DosLoadModule(szError, sizeof(szError), szFile, &hModPlug) == NO_ERROR)
                {
                    //Load the CBZPluginInfo function so we can Query the plugin's Information
                    if (DosQueryProcAddr(hModPlug, 0, "CBZPluginInfo", (PFN *) & (pPluginInfoFunction)) == NO_ERROR)
                    {
                        pPluginInfoFunction(&pluginInfo);

                        if (pluginInfo.lWindowTypes & Win_Type)
                        {
                            //Add the Plugin's Name to the AvailablePlugins ListBox.
                            index = (SHORT) WinSendMsg(hwndLBAvailable, LM_INSERTITEM,
                                                       MPFROMSHORT((SHORT) LIT_SORTASCENDING),
                                                       MPFROMP(pluginInfo.PluginName));

                            //Add the Plugin's DLL Name to the offscreen AvailablePluginDLLs ListBox.
                            // keeping it synchronized with the AvailablePlugins ListBox
                            WinSendMsg(hwndLBAvailableDLL, LM_INSERTITEM,
                                       MPFROMSHORT((SHORT) index),
                                       MPFROMP(dllName));
                        }
                    }
                    DosFreeModule(hModPlug);
                }               //end DosLoadModule if

            }                   //end NO_MORE_FILES if

        }                       //end while

        DosFindClose(hdirFindHandle);
    }                           //end else

    //plugins loaded sucessfully
    return (TRUE);
}
コード例 #11
0
// AddPlugin(hwnd, pTBData, dllName, appName, bActive)
//    hwnd     --> Handle of the calling window
//    pTBData  --> Pointer to the titlebar's CandyBarZ data structure
//    dllName  --> DLL name of the plugin to add to the pTBData structure
//    appName  --> Name of the app to add this plugin to. NULL = default(sharedMem)
//    bActive  --> Whether the plugin should be added to the active or inactive section
BOOL AddPlugin(HWND hwnd, CBZDATA * pCBZData, char dllName[], char appName[])
{
    int index;
    char szError[32];
    char szFile[CCHMAXPATH];
    char szBase[CCHMAXPATH];
    PINITFN pInitFn;

    //determine the index for the added plugin in the plugin array
    index = pCBZData->cbPlugins;

    //Set some initial data for the plugin.
    pCBZData->Plugins[index].bActiveEnabled = TRUE;
    pCBZData->Plugins[index].bInactiveEnabled = TRUE;
    pCBZData->Plugins[index].pData = NULL;
    pCBZData->Plugins[index].cbData = 0;
    strcpy(pCBZData->Plugins[index].szPluginDLL, dllName);

    //plugins are not necessarily in the LIBPATH so
    //    find the full path to the plugin dll.
    PrfQueryProfileString(HINI_USERPROFILE,
                          "CandyBarZ",
                          "BasePath",
                          NULL,
                          szBase,
                          CCHMAXPATH);
    strcat(szBase, "plugins");
    _makepath(szFile, NULL, szBase, pCBZData->Plugins[index].szPluginDLL, "DLL");

    //Load the Plugin Module
    if (DosLoadModule(szError, sizeof(szError), szFile,
                      &(pCBZData->Plugins[index].hModDll)) != NO_ERROR)
    {
        //Error loading the dll...disable this plugin!
        PSUTErrorFunc(hwnd,
                      "Error",
                      "AddPlugin",
                      "Error Loading the Plugin Module",
                      0UL);
        return (FALSE);
    }

    //Query the Plugin's Window Procedure.
    if (DosQueryProcAddr(pCBZData->Plugins[index].hModDll, 0, "CBZPluginWndProc",
                         (PFN *) & (pCBZData->Plugins[index].pPluginWndProc)) != NO_ERROR)
    {
        //error getting the Plugin's WndProc...disable the plugin!
        PSUTErrorFunc(hwnd,
                      "Error",
                      "AddPlugin",
                      "Error Quering CBZPluginWndProc!",
                      0UL);
        //clean up
        DosFreeModule(pCBZData->Plugins[index].hModDll);
        return (FALSE);
    }

    //Query The Plugin's CBZInit Function
    if (DosQueryProcAddr(pCBZData->Plugins[index].hModDll, 0, "CBZInit",
                         (PFN *) & (pInitFn)) != NO_ERROR)
    {
        PSUTErrorFunc(hwnd,
                      "Error",
                      "AddPlugin",
                      "Error Quering CBZInit!",
                      0UL);
        //error in Plugin's initialization...disable the plugin!
        pCBZData->Plugins[index].bActiveEnabled = FALSE;
        pCBZData->Plugins[index].bInactiveEnabled = FALSE;
        DosFreeModule(pCBZData->Plugins[index].hModDll);
        return (FALSE);
    }
    //Call the plugins Init function.
    if (!pInitFn(NULLHANDLE, "", "TITLEBAR", (PVOID *) & (pCBZData->Plugins[index].pData)))
    {
        PSUTErrorFunc(hwnd,
                      "Error",
                      "AddPlugin",
                      "Error running the plugin's CBZInit function!",
                      0UL);
        //error in Plugin's initialization...disable the plugin!
        pCBZData->Plugins[index].bActiveEnabled = FALSE;
        pCBZData->Plugins[index].bInactiveEnabled = FALSE;
        DosFreeModule(pCBZData->Plugins[index].hModDll);
        return (FALSE);
    }

    //Query the address of the plugin's Render function.
    if (DosQueryProcAddr(pCBZData->Plugins[index].hModDll, 0, "CBZPluginRender",
                         (PFN *) & (pCBZData->Plugins[index].pfnPluginRender)) != NO_ERROR)
    {
        //Error getting CBZPluginRender function!
        PSUTErrorFunc(hwnd,
                      "Error",
                      "AddPlugin",
                      "Error Quering CBZPluginRender!",
                      0UL);

        DosFreeModule(pCBZData->Plugins[index].hModDll);
        DosFreeMem(pCBZData->Plugins[index].pData);
        return (FALSE);
    }

    //update the plugin count.
    pCBZData->cbPlugins++;

    return (TRUE);              //plugin add sucessfull!

}
コード例 #12
0
main()
{
  HAB hab;
  HMQ hmq;
  ULONG keyLength;
  char profileName[20];
  
  hab = WinInitialize( 0 );
  if(hab) {
    hmq = WinCreateMsgQueue( hab, 100UL );
    if(hmq) {
      sprintf(profileName,"cdrecord.ini");		
      hini=PrfOpenProfile(WinQueryAnchorBlock(HWND_DESKTOP),profileName);
      if(!hini) {
        WinMessageBox(  HWND_DESKTOP,
                        HWND_DESKTOP,
                        "Warning! Cannot open Ini-file!",
                        "",
                        0UL,
                        MB_OK | MB_ICONEXCLAMATION );
        WinDestroyMsgQueue( hmq );
        WinTerminate( hab );
        return( 1 );
      }/* end of if(!hini) */
      
      keyLength=PrfQueryProfileString(hini,"CDWriter","cdrecord","",chrCDRecord,sizeof(chrCDRecord));
      if(keyLength==1){
        if( WinDlgBox( HWND_DESKTOP, NULLHANDLE, CDSettingsDlgProc, NULLHANDLE,DLGID_SETUP, 0 ) == DID_ERROR )
          {
            WinMessageBox(  HWND_DESKTOP,
                            HWND_DESKTOP,
                            "Warning! Cannot open Settings dialog!",
                            "",
                            0UL,
                            MB_OK | MB_ICONEXCLAMATION );
            WinDestroyMsgQueue( hmq );
            WinTerminate( hab );
            if(hini)PrfCloseProfile(hini);
            return( 1 );
          }
        if(!PrfWriteProfileString(hini,"CDWriter","cdrecord",chrCDRecord)){
          WinMessageBox(  HWND_DESKTOP,
                          HWND_DESKTOP,
                          "Warning! Cannot write to Ini-file!",
                          "",
                          0UL,
                          MB_OK | MB_ICONEXCLAMATION );
          WinDestroyMsgQueue( hmq );
          WinTerminate( hab );
          if(hini)PrfCloseProfile(hini);
          return( 1 );
        }
        
        if(!PrfWriteProfileString(hini,"CDWriter","cdroptions",chrCDROptions)){
          WinMessageBox(  HWND_DESKTOP,
                          HWND_DESKTOP,
                          "Warning! Cannot write to Ini-file!",
                          "",
                          0UL,
                          MB_OK | MB_ICONEXCLAMATION );
          WinDestroyMsgQueue( hmq );
          WinTerminate( hab );
          if(hini)PrfCloseProfile(hini);
          return( 1 );
        };
      }
      PrfQueryProfileString(hini,"CDWriter","cdroptions","",chrCDROptions,sizeof(chrCDROptions));
      
      if( WinDlgBox( HWND_DESKTOP, NULLHANDLE, CDToolsDlgProc, NULLHANDLE,DLGID_CDTOOLS, 0 ) == DID_ERROR )
        {
          WinDestroyMsgQueue( hmq );
          WinTerminate( hab );
          if(hini)PrfCloseProfile(hini);
          DosBeep(100,600);
          return( 1 );
        }
      if(hini)PrfCloseProfile(hini);
      WinDestroyMsgQueue( hmq );
    }
    WinTerminate( hab );
  }
  return( 0 );	
}
コード例 #13
0
/*@ XPrinterDevice::SetupPrinter(char *title, XFrameWindow * owner, XString * queueName, XString * fileName)
@remarks Let the user select the printer-queue in a dialog. The dialog is loaded from OOLRES.DLL which must be installed.
@parameters
<t 'ø' c=2>
øchar *title            øthe title of the dialog
øXFrameWindow * owner   øowner window. If NULL, the dialog for the printer-setup is not opened
                         and the  queue given in parameter 3 is initialized directly
øXString * queueName      ødefault queue-name (can be null)
øXString * fileName      øbuffer for a fileName if the user wants to print to a file (if NULL no fiflename is stored)
</t>
@returns BOOL success
*/
BOOL XPrinterDevice::SetupPrinter(const char *title, const XFrameWindow * owner, XString * queueName, XString * fileName)
{
   BOOL fOK;
   CHAR szDefaultQueue[196];
   CHAR szSavedQueue[196];
   CHAR szWork[196];
   PCHAR pch;
   PPRQINFO3 pqi;
   SIZEL sizel;
   ULONG cReturned;
   ULONG cTotal;
   ULONG cbNeeded;
   ULONG ul;
   ULONG ulrc;

   // Caller must set these items before calling.
   if (!pSetup->hab || !pSetup->lWorldCoordinates)
      return FALSE;

   // no good unless I can open a PS
   pSetup->pDevOpenData = NULL;

   // Close the info DC's and PS's from any previous call.
   if (pSetup->hpsPrinterInfo)
   {
      GpiAssociate(pSetup->hpsPrinterInfo, (HDC) 0);
      GpiDestroyPS(pSetup->hpsPrinterInfo);
      pSetup->hpsPrinterInfo = (HPS) 0;
   }

   if (pSetup->hdcPrinterInfo)
   {
      DevCloseDC(pSetup->hdcPrinterInfo);
      pSetup->hdcPrinterInfo = (HDC) 0;
   }

   if (pSetup->pQueueInfo)
   {
      // Free the array of PRQINFO3 from previous call.
      free(pSetup->pQueueInfo);
      pSetup->pQueueInfo = NULL;
   }

   // Query how many queues exist on this computer and the
   // number of bytes needed to hold the array.
   ul = SplEnumQueue(NULL, 3, NULL, 0, &cReturned, &cTotal, &cbNeeded, NULL);
   if (cTotal == 0)
   {
      // There are no queues on this computer!
      pSetup->cQueues = 0;
      return FALSE;
   }

   // Allocate memory to store the newly enumerated queue information.
   pSetup->pQueueInfo = (PRQINFO3 *) malloc(cbNeeded);
   if (!pSetup->pQueueInfo)
      return FALSE;

   // Call system again to get the array of PRQINFO3 structures.
   ul = SplEnumQueue(NULL, 3, pSetup->pQueueInfo, cbNeeded, &cReturned, &cTotal, &cbNeeded, NULL);
   if (ul != 0 ||
      cReturned != cTotal)
      return FALSE;
   pSetup->cQueues = cReturned;

   // Establish a default queue -- might need it.
   // Profiled queue name ends with a semicolon.
   ul = PrfQueryProfileString(HINI_PROFILE, (PSZ) "PM_SPOOLER", (PSZ) "QUEUE", NULL, szDefaultQueue, 196);
   if (ul > 1)
   {
      // Trim off semicolon.
      pch = strchr(szDefaultQueue, ';');
      *pch = 0;
   }
   else
   {
      // Hmmmm. Use the first one queue from the enumeration.
      strcpy(szDefaultQueue, (char*) pSetup->pQueueInfo->pszName);
   }
   if (!strlen(szDefaultQueue))
      return FALSE;

   if (0 == strlen(pSetup->szPreferredQueue))
   {
      // No queue preference; use default.
      strcpy(pSetup->szPreferredQueue, szDefaultQueue);

      // Don't expect to see DRIVDATA without queue name.
      // if(! pSetup->pDriverData ) return FALSE;
   }

   if (queueName)
   {
      if (!queueName->IsEmpty())
      {
         pSetup->fToFile = FALSE;
         strcpy(pSetup->szPreferredQueue, (char *) *queueName);
      }
      if (fileName)
      {
         if (!fileName->IsEmpty())
         {
            pSetup->fToFile = TRUE;
            strcpy(pSetup->szFileName, (char *) *fileName);
         }
      }
   }

   pqi = FindQueue(pSetup);
   if (!pqi)
   {
      strcpy(pSetup->szPreferredQueue, szDefaultQueue);
      if (pSetup->pDriverData)
      {
         free(pSetup->pDriverData);
         pSetup->pDriverData = NULL;
      }
   }
   else
   {
      fOK = TRUE;

      if (pSetup->pDriverData)
      {
         fOK = fOK && (pqi->pDriverData->cb == pSetup->pDriverData->cb);
         fOK = fOK && (0 == strcmp(pqi->pDriverData->szDeviceName, pSetup->pDriverData->szDeviceName));
      }

      if (!fOK)
      {
         free(pSetup->pDriverData);
         pSetup->pDriverData = NULL;
      }
   }

   pqi = FindQueue(pSetup);

   if (!pSetup->pDriverData)
   {
      pSetup->pDriverData = (DRIVDATA *) malloc(pqi->pDriverData->cb);
      if (!pSetup->pDriverData)
      {
         ulrc = FALSE;
         return ulrc;
      }
      memcpy(pSetup->pDriverData, pqi->pDriverData, pqi->pDriverData->cb);
   }

   if (!pSetup->pDriverData || pSetup->pDriverData->cb <= 0 || pSetup->pDriverData->cb != pqi->pDriverData->cb || strcmp(pqi->pDriverData->szDeviceName, pSetup->pDriverData->szDeviceName))
      return FALSE;

   memcpy(pqi->pDriverData, pSetup->pDriverData, pSetup->pDriverData->cb);

   strcpy(szSavedQueue, pSetup->szPreferredQueue);

   if (owner)
   {
      XCountryInfo info;
      XResourceLibrary lib( "oolres");
      LONG dlgID;

      switch (info.GetCountry())
      {
      case 39:            // italy
         dlgID = IDD_SELPRINT_ITA;
         break;
      case 2:             // can francais
      case 33:            // france
      case 32:            // belgien
         dlgID = IDD_SELPRINT_FRA;
         break;
      case 49:            // german
         dlgID = IDD_SELPRINT_GER;
         break;
      default:            // english
         dlgID = IDD_SELPRINT_ENG;
      }
      XResource res(dlgID, &lib);

      PrinterDialog *printerDialog = new PrinterDialog(owner, pSetup, &res);
//      printerDialog->SetText((char*) title);
      LONG result = printerDialog->Start();
      if (result == DID_CANCEL)
         return FALSE;
   }
   else
   {
      if (queueName)
      {
         pSetup->fToFile = FALSE;
         strcpy(pSetup->szPreferredQueue, (char *) *queueName);

         if (fileName)
         {
            pSetup->fToFile = TRUE;
            strcpy(pSetup->szFileName, (char *) *fileName);
         }
      }
   }

   *queueName = "";
   *fileName = "";

   pqi = FindQueue(pSetup);
   if (!pqi)
      return FALSE;

   if (0 != strcmp(szSavedQueue, pSetup->szPreferredQueue))
   {
      if (!pSetup->pDriverData)
         return FALSE;
      free(pSetup->pDriverData);

      pSetup->pDriverData = (DRIVDATA *) malloc(pqi->pDriverData->cb);
      if (!pSetup->pDriverData)
      {
         ulrc = FALSE;
         return ulrc;
      }
      pSetup->pDriverData->cb = pqi->pDriverData->cb;
   }

   if (!pSetup->pDriverData || !pSetup->pDriverData->cb == pqi->pDriverData->cb)
      return FALSE;
   memcpy(pSetup->pDriverData, pqi->pDriverData, pqi->pDriverData->cb);

   if (pSetup->fToFile)
   {
      pSetup->lDCType = OD_DIRECT;
      pSetup->devopenstruc.pszLogAddress = (PSZ) pSetup->szFileName;
   }
   else
   {
      pSetup->lDCType = OD_QUEUED;
      pSetup->devopenstruc.pszLogAddress = (PSZ) pSetup->szPreferredQueue;
   }

   strcpy(szWork, (char*) pqi->pszDriverName);
   pch = strchr(szWork, '.');
   if (pch)
      *pch = 0;

   if (pSetup->devopenstruc.pszDriverName)
      free(pSetup->devopenstruc.pszDriverName);

   pSetup->devopenstruc.pszDriverName = (PSZ) malloc(1 + strlen(szWork));
   if (!pSetup->devopenstruc.pszDriverName)
      return FALSE;

   strcpy( (char*) pSetup->devopenstruc.pszDriverName, szWork);

   pSetup->devopenstruc.pdriv = pSetup->pDriverData;
   pSetup->devopenstruc.pszDataType = (PSZ) "PM_Q_STD";

   pSetup->hdcPrinterInfo = DevOpenDC(pSetup->hab, OD_INFO, (PSZ) "*", 4, (PDEVOPENDATA) & pSetup->devopenstruc, (HDC) 0);
   if (!pSetup->hdcPrinterInfo)
      return FALSE;

   sizel.cx = 0;
   sizel.cy = 0;
   pSetup->hpsPrinterInfo = GpiCreatePS(pSetup->hab, pSetup->hdcPrinterInfo, &sizel, pSetup->lWorldCoordinates | GPIA_ASSOC);

   if (GPI_ERROR == pSetup->hpsPrinterInfo)
   {
      DevCloseDC(pSetup->hdcPrinterInfo);
      pSetup->hdcPrinterInfo = (HDC) 0;
      pSetup->hpsPrinterInfo = (HPS) 0;
      return FALSE;
   }

   pSetup->pDevOpenData = (PDEVOPENDATA) & pSetup->devopenstruc;

   *queueName = pSetup->szPreferredQueue;
   if (pSetup->fToFile)
      *fileName = pSetup->szFileName;
   return TRUE;
}
コード例 #14
0
ファイル: ZProfile.cpp プロジェクト: greeduomacro/Iris1
ZExport (ZString) ZProfile::value (const ZString & aValueName)
{
  ZFUNCTRACE_DEVELOP ("ZProfile::value(const ZString& aValueName)");
#ifdef ZC_WIN
  openPath (zFalse);

  DWORD dataType, size;
  if (!RegQueryValueEx ((HKEY) iPathHandle, aValueName, 0,
                        &dataType, NULL, &size) == ERROR_SUCCESS)
    ZTHROWEXC (ValueNotFound);

  if (size)
      {
        ZString str (0, size);
        RegQueryValueEx ((HKEY) iPathHandle, aValueName, 0,
                         NULL, (LPBYTE) (char *) str, (LPDWORD) & size);

        switch (dataType)
            {
            case 1:            // String
            case 2:            // ExpandString
            case 7:            // MultiString
              if (str.size () > 0 && str[str.size ()] == 0)
                return str.subString (1, str.size ());
            default:;
            }                   // switch
      }                         // if
#endif
#ifdef ZC_OS2
  if (!iPath.size ())
    ZTHROWEXC (MissingPath);
  if (!aValueName.size ())
    ZTHROWEXC (MissingValueName);
  openRoot ();

  // query size of data
  unsigned long size;
  if (!PrfQueryProfileSize (iRootHandle, iPath, aValueName, &size))
    throwSysErr (PrfQueryProfileSizeName);

  if (size > 0)
      {
        ZString buf (0, size++);

        // try to get as string first
        PrfQueryProfileString (iRootHandle, iPath, aValueName, "", buf, size);
        ERRORID err = WinGetLastError (iHab);
        if (err == 0)
            {
              if (buf[buf.size ()] == 0
                  && buf.subString (1, buf.size () - 1).isPrintable ())
                return buf.subString (1, buf.size () - 1);
              return buf;
            }                   // if

        if (ERRORIDERROR (err) != PMERR_INVALID_ASCIIZ)
          throwSysErr (PrfQueryProfileStringName);

        // try to get binary data
        if (!PrfQueryProfileData (iRootHandle, iPath, aValueName, buf, &size))
          throwSysErr (PrfQueryProfileDataName);
        return buf;
      }                         // if
#endif
  return ZString ();
}                               // value
コード例 #15
0
BOOL LoadNLS(VOID)
{
    BOOL Proceed = TRUE;

    if (PrfQueryProfileString(HINI_USER,
                              "XWorkplace",
                              "XFolderPath",
                              "",
                              G_szNLSDLL,
                              sizeof(G_szNLSDLL))
                   < 3)

    {
        DisplayError("NetscapeDDE was unable to determine the location of the "
                     "XWorkplace National Language Support DLL, which is "
                     "required for operation. The OS2.INI file does not contain "
                     "this information. "
                     "NetscapeDDE cannot proceed. Please re-install XWorkplace.");
        Proceed = FALSE;
    }
    else
    {
        CHAR    szLanguageCode[50] = "";

        // now compose module name from language code
        PrfQueryProfileString(HINI_USERPROFILE,
                              "XWorkplace", "Language",
                              "001",
                              (PVOID)szLanguageCode,
                              sizeof(szLanguageCode));
        // allow '?:\' for boot drive
        // V0.9.19 (2002-06-08) [umoeller]
        if (G_szNLSDLL[0] == '?')
        {
            ULONG ulBootDrive;
            DosQuerySysInfo(QSV_BOOT_DRIVE, QSV_BOOT_DRIVE,
                            &ulBootDrive,
                            sizeof(ulBootDrive));
            G_szNLSDLL[0] = (CHAR)ulBootDrive + 'A' - 1;
        }

        strcat(G_szNLSDLL, "\\bin\\xfldr");
        strcat(G_szNLSDLL, szLanguageCode);
        strcat(G_szNLSDLL, ".dll");

        // try to load the module
        if (DosLoadModule(NULL,
                          0,
                          G_szNLSDLL,
                          &G_hmodNLS))
        {
            DisplayError("NetscapeDDE was unable to load \"%s\", "
                         "the National Language DLL which "
                         "is specified for XWorkplace in OS2.INI.",
                         G_szNLSDLL);
            Proceed = FALSE;
        }
    }

    return Proceed;
}
コード例 #16
0
ファイル: winstall.c プロジェクト: OS2World/APP-COMM-ComScope
MRESULT  EXPENTRY fnwpClient(HWND hwnd,USHORT msg,MPARAM mp1,MPARAM mp2)
  {
  POINTL  ptl;
  HPS     hps;
  RECTL   rcl;
  ORIG    Origin;
  BYTE    bVkey;
  BYTE    chKey;
  PSWP    pswp;
  USHORT  usCxMaxWnd;
  static  ORIG OrigRestor;
  USHORT   Command;
  CHAR szMessage[100];
  CHAR szCaption[81];
  ULONG cbDataSize;

  switch(msg)
    {
    case WM_CREATE:
      CreatePS(hwnd);
      if (bFalseStart)
        WinPostMsg(hwndClient,UM_FALSE_START,0,0);
      else
        WinPostMsg(hwndClient,UM_INITMENUS,0,0);
      break;
    case UM_FALSE_START:
      if (bConfigurationOnly > 1)
        MessageBox(HWND_DESKTOP,szFalseStart2);
      else
        MessageBox(HWND_DESKTOP,szFalseStart1);
    case WM_CLOSE:
        WinPostMsg(hwnd,WM_QUIT,0L,0L);
      break;
    case UM_INITMENUS:
      sprintf(pszPath,"~%s...",szConfigDDname);
      WinSendMsg(WinWindowFromID(stInst.hwndFrame,FID_MENU),MM_SETITEMTEXT,(MPARAM)IDM_CONFIG_DD,pszPath);
      if (strlen(szConfigAppName) != 0)
        {
        sprintf(pszPath,"~%s...",szConfigAppName);
        WinSendMsg(WinWindowFromID(stInst.hwndFrame,FID_MENU),MM_SETITEMTEXT,(MPARAM)IDM_CONFIG_APP,pszPath);
        PrfQueryProfileString(HINI_USERPROFILE,szConfigAppName,"Configuration",0L,
                                                       stInst.paszStrings[CONFIGAPPLIBRARYSPEC],
                                                       stInst.ulMaxPathLen);
        if (strlen(stInst.paszStrings[CONFIGAPPLIBRARYSPEC]) == 0)
          MenuItemEnable(stInst.hwndFrame,IDM_CONFIG_APP,FALSE);
        cbDataSize = sizeof(HOBJECT);
        if (!PrfQueryProfileData(hSourceProfile,szConfigAppName,"WPSobject",&stPageCFG.hObject,&cbDataSize))
          stPageCFG.hObject = 0;
        }
      if (bConfigurationOnly)
        MenuItemEnable(stInst.hwndFrame,IDM_SELECT,FALSE);
      if (!bUninstall)
        MenuItemEnable(stInst.hwndFrame,IDM_UNINSTALL,FALSE);
      if (!bPreviousInstallation)
        if (!bCOMiInstalled)
          MenuItemEnable(stInst.hwndFrame,IDM_SETUP,FALSE);
//      MenuItemEnable(stInst.hwndFrame,IDM_TRANSFER,FALSE);
      break;
    case WM_DESTROY:
      GpiDestroyPS(hpsPs);
      break;
    case WM_HELP:
      if (SHORT1FROMMP(mp2) & CMDSRC_PUSHBUTTON)
        {
        DisplayHelpPanel(SHORT1FROMMP(mp1));
        return((MRESULT)FALSE);
        }
      break;
    case HM_QUERY_KEYS_HELP:
      return (MRESULT)HLPP_KEYS;
    case WM_ACTIVATE:
      if(SHORT1FROMMP(mp1))
        {
        WinSetFocus(HWND_DESKTOP,stInst.hwndFrame);
        WinSendMsg(WinQueryHelpInstance(hwndClient),HM_SET_ACTIVE_WINDOW,0L,0L);
        }
      break;
    case WM_PAINT:
      ClientPaint(hwnd);
      break;
    case WM_COMMAND:
        InstallCommand(hwnd,SHORT1FROMMP(mp1));
      break;
    default:
      return WinDefWindowProc(hwnd,msg,mp1,mp2);
    }
  return(FALSE);
  }
コード例 #17
0
ファイル: nls.cpp プロジェクト: ErisBlastar/osfree
VOID nlsGetAMPM(PCOUNTRYAMPM pampm)
{
    if (   (doshIsWarp4()==3)
        && (!fUniResolved)
       )
    {
        HMODULE hmodUCONV = NULLHANDLE,
                hmodLIBUNI = NULLHANDLE;

        fUniResolved = TRUE;
        if (   (doshResolveImports("UCONV.DLL",
                                   &hmodUCONV,
                                   G_aResolveFromUCONV,
                                   sizeof(G_aResolveFromUCONV) / sizeof(G_aResolveFromUCONV[0]))
                == NO_ERROR)
            && (doshResolveImports("LIBUNI.DLL",
                                   &hmodLIBUNI,
                                   G_aResolveFromLIBUNI,
                                   sizeof(G_aResolveFromLIBUNI) / sizeof(G_aResolveFromLIBUNI[0]))
                == NO_ERROR)
           )
            fUniOK = TRUE;
    }

    if (   (doshIsWarp4()==3)   // V1.0.5 (2006-05-29) [pr]
        && fUniOK
       )
    {
        UconvObject         uconv_object;

        if (G_UniCreateUconvObject((UniChar *)L"",
                                   &uconv_object) == ULS_SUCCESS)
        {
            LocaleObject locale_object;

            if (G_UniCreateLocaleObject(UNI_UCS_STRING_POINTER,
                                        (UniChar *)L"",
                                        &locale_object) == ULS_SUCCESS)
            {
                int i;
                struct LOCALE_ITEMLIST
                {
                    LocaleItem      lclItem;
                    PVOID           vTarget;
                    int             iType;
                } itemList[] = {
                    { LOCI_s2359, &pampm->sz2359, 3 },
                    { LOCI_s1159, &pampm->sz1159, 3 }
                               };

                for (i = 0;
                     i < sizeof(itemList) / sizeof(itemList[0]);
                     i++)
                {
                    UniChar *pItem;

                    if (G_UniQueryLocaleItem(locale_object,
                                             itemList[i].lclItem,
                                             &pItem) == ULS_SUCCESS)
                    {
                        int iLen = G_UniStrlen(pItem) + 1;
                        PSZ pszResult = (PSZ)malloc(iLen);

                        if (G_UniStrFromUcs(uconv_object,
                                            pszResult,
                                            pItem,
                                            iLen) == ULS_SUCCESS)
                        {
                            switch(itemList[i].iType)
                            {
                                case 1:
                                    *((ULONG *) itemList[i].vTarget) = atol(pszResult);
                                    break;

                                case 2:
                                    *((CHAR *) itemList[i].vTarget) = pszResult[0];
                                    break;

                                case 3:
                                    strcpy ((PCHAR)(itemList[i].vTarget), pszResult);
                                    break;
                            }
                        }

                        free(pszResult);
                        G_UniFreeMem(pItem);
                    }
                }

                G_UniFreeLocaleObject(locale_object);
            }

            G_UniFreeUconvObject(uconv_object);
        }
    }
    else
    {
        PrfQueryProfileString(HINI_USER,
                              "PM_National",
                              "s2359",        // key
                              "PM",           // default
                              pampm->sz2359,
                              sizeof(pampm->sz2359));

        PrfQueryProfileString(HINI_USER,
                              "PM_National",
                              "s1159",        // key
                              "AM",           // default
                              pampm->sz1159,
                              sizeof(pampm->sz1159));
    }
}
コード例 #18
0
ファイル: winstall.c プロジェクト: OS2World/APP-COMM-ComScope
void ConfigQuickPage(HWND hwnd)
  {
  BOOL bSuccess = FALSE;
  HMODULE hMod;
  PFN pfnProcess;
  char szCaption[40];
  char szMessage[100];
  INFODLG stInfoDlg;

  stInst.bAppConfigured = FALSE;
  if (stInst.paszStrings[CONFIGAPPLIBRARYSPEC][0] == 0)
    {
    if (PrfQueryProfileString(HINI_USERPROFILE,szConfigAppName,"Configuration",0L,
                                                stInst.paszStrings[CONFIGDDLIBRARYSPEC],
                                                stInst.ulMaxPathLen) == 0)
      strcpy(stInst.paszStrings[CONFIGAPPLIBRARYSPEC],"QPG_CFG.DLL");
    }
  if (DosLoadModule(0,0,stInst.paszStrings[CONFIGAPPLIBRARYSPEC],&hMod) != NO_ERROR)
    {
    sprintf(stInst.paszStrings[CONFIGAPPLIBRARYSPEC],"%s\\QPG_CFG.DLL",stInst.pszSourcePath);
    if (DosLoadModule(0,0,stInst.paszStrings[CONFIGAPPLIBRARYSPEC],&hMod) != NO_ERROR)
      {
      sprintf(szCaption,"Configuration cannot be completed.");
      sprintf(szMessage,"Library %s is invalid or does not exist.",stInst.paszStrings[CONFIGAPPLIBRARYSPEC]);
      WinMessageBox(HWND_DESKTOP,
                    stInst.hwndFrame,
                    szMessage,
                    szCaption,
                    HLPP_MB_LIBRARY_BAD,
                   (MB_OK | MB_HELP | MB_WARNING));
      sprintf(szBannerTwo,"Installation is not complete");
      szBannerOne[0] = 0;
      ClientPaint(hwndClient);
      return;
      }
    }
  else
    {
    if (DosQueryProcAddr(hMod,0,szConfigAppFunctionName,(PFN *)&pfnProcess) == NO_ERROR)
      {
      stPageCFG.cbSize = sizeof(COMICFG);
      stPageCFG.hwndFrame = stInst.hwndFrame;
      stPageCFG.hab = stInst.hab;
      stPageCFG.pszHelpFileName = szConfigAppHelpFileName;
      stPageCFG.pszConfigFileName = szPagerFileName;
      stPageCFG.pszDestPath = pszPath;
      stPageCFG.pszDestPath = stInst.pszAppsPath;
      if (stInst.byItemCount == 0)
        stPageCFG.hObject = 0;
      bSuccess = pfnProcess(&stPageCFG);
      }
    DosFreeModule(hMod);
    }
  if (bSuccess)
    {
    sprintf(szCaption,"Configuration is complete.");
    sprintf(szMessage,"%s has been successfully configured.",szConfigAppName);
    WinMessageBox(HWND_DESKTOP,
                  stInst.hwndFrame,
                  szMessage,
                  szCaption,
                  HLPP_MB_CONFIG_OK,
                 (MB_OK | MB_HELP | MB_INFORMATION));
    stInst.bAppConfigured = TRUE;
//    szBannerOne[0] = 0;
    if (stInst.bFilesCopied)
      {
      if (!stInst.bDDconfigured)
        {
        sprintf(szBannerTwo,"%s Configuration is complete",szConfigAppName);
        sprintf(szBannerOne,"Select \"Configuration | %s...\" to complete Installation",szConfigDDname);
        }
      else
        sprintf(szBannerTwo,"Installation is complete");
      }
    else
      sprintf(szBannerTwo,"%s Configuration is complete",szConfigAppName);
    ClientPaint(hwndClient);
    if (stInst.bFilesCopied)
      {
      if (strlen(szInfoFileName) != 0)
        {
        stInfoDlg.cbSize = sizeof(INFODLG);
        stInfoDlg.pszFileName = szInfoFileName;
        stInfoDlg.pszCaption = szInfoCaption;
        WinDlgBox(HWND_DESKTOP,
                  hwnd,
           (PFNWP)fnwpInfoDlgProc,
            (LONG)NULL,
                  EVAL_MSG,
             (PVOID)&stInfoDlg);
        }
      }
    }
  else
    {
    if (stInst.bFilesCopied)
      {
      sprintf(szCaption,"Configuration is not complete.");
      sprintf(szMessage,"You must select the \"Configuration | %s...\" menu item again to complete installation.",szConfigAppName);
      WinMessageBox(HWND_DESKTOP,
                    stInst.hwndFrame,
                    szMessage,
                    szCaption,
                    HLPP_MB_CONFIG_BAD,
                   (MB_OK | MB_HELP | MB_WARNING));
      sprintf(szBannerTwo,"Installation is not complete");
      szBannerOne[0] = 0;
      ClientPaint(hwndClient);
      }
    }
  }
/*����������������������������������������������������������������������������*/
BOOL ReadSpyINI(HWND      hFrame,   /* HWND(Agent's frame) */
                LONG      Agent,    /* one-origin "agent" */
                PINI_DATA pIni)     /* INI data to read */
{
  CHAR szAgent[32];

  HINI hINI          = NULLH;
  BOOL bOK           = BOOL_FALSE;

  /*������������������������������������������������������������������������Ŀ*/
  /*� Set the INI data to 'default' values...                                �*/
  /*�                                                                        �*/
  /*�                                                                        �*/
  /*� - list font                                                            �*/
  /*�                                                                        �*/
  /*� - window position:  x  = left edge                                     �*/
  /*�                     y  = above bottom row of icons                     �*/
  /*�                     cX = 6/10 screen width                             �*/
  /*�                     cY = 4/10 screen height                            �*/
  /*��������������������������������������������������������������������������*/
  memset(pIni, 0, sizeof(*pIni) );

  strcpy(pIni->szListFont, szDefFont);
  strcpy(pIni->szLog,      szDefLog);
  strcpy(pIni->szProfile,  szDefProfile);

  pIni->swpAgent.x  = 0;

  pIni->swpAgent.y  = (SHORT)
                      (WinQuerySysValue(HWND_DESKTOP, SV_CYICON)      *2);

  pIni->swpAgent.cx = (SHORT)
                      (WinQuerySysValue(HWND_DESKTOP, SV_CXFULLSCREEN)*6)/10;

  pIni->swpAgent.cy = (SHORT)
                      (WinQuerySysValue(HWND_DESKTOP, SV_CYFULLSCREEN)*4)/10;

  /*������������������������������������������������������������������������Ŀ*/
  /*� Open the PMSPY "profile"                                               �*/
  /*��������������������������������������������������������������������������*/
  if ( (hINI = PrfOpenProfile( WinQueryAnchorBlock(hFrame),
                               szINI)) != NULLH )
  {
    /*����������������������������������������������������������������������Ŀ*/
    /*� Determine which "agent" this data is for                             �*/
    /*������������������������������������������������������������������������*/
    sprintf(szAgent, Strings[IDS_FMT_AGENT], Agent);

    /*����������������������������������������������������������������������Ŀ*/
    /*� Read Agent's previous FONT                                           �*/
    /*������������������������������������������������������������������������*/
    PrfQueryProfileString(hINI,
                          szAgent,
                          szKeyFont,
                          pIni->szListFont,           /* default */
                          pIni->szListFont,           /* target & size */
                          (LONG)sizeof(pIni->szListFont) );

    /*����������������������������������������������������������������������Ŀ*/
    /*� Read Agent's previous LOG                                            �*/
    /*������������������������������������������������������������������������*/
    PrfQueryProfileString(hINI,
                          szAgent,
                          szKeyLog,
                          pIni->szLog,                /* default */
                          pIni->szLog,                /* target & size */
                          (LONG)sizeof(pIni->szLog) );

    /*����������������������������������������������������������������������Ŀ*/
    /*� Read Agent's previous PROfile                                        �*/
    /*������������������������������������������������������������������������*/
    PrfQueryProfileString(hINI,
                          szAgent,
                          szKeyPro,
                          pIni->szProfile,            /* default */
                          pIni->szProfile,            /* target & size */
                          (LONG)sizeof(pIni->szProfile) );

    /*����������������������������������������������������������������������Ŀ*/
    /*� Read Agent's previous WINDOW POSITION                                �*/
    /*������������������������������������������������������������������������*/
    pIni->swpAgent.x  = PrfQueryProfileInt(hINI,
                                           szAgent,
                                           szKeyPosX,
                                           pIni->swpAgent.x);   /* default */

    pIni->swpAgent.y  = PrfQueryProfileInt(hINI,
                                           szAgent,
                                           szKeyPosY,

                                           pIni->swpAgent.y);   /* default */
    pIni->swpAgent.cx = PrfQueryProfileInt(hINI,
                                           szAgent,
                                           szKeySizeCX,
                                           pIni->swpAgent.cx);  /* default */

    pIni->swpAgent.cy = PrfQueryProfileInt(hINI,
                                           szAgent,
                                           szKeySizeCY,
                                           pIni->swpAgent.cy);  /* default */

    /*����������������������������������������������������������������������Ŀ*/
    /*� Close the PMSPY "profile"                                            �*/
    /*������������������������������������������������������������������������*/
    PrfCloseProfile(hINI);

    bOK = BOOL_TRUE;
  }

  return( bOK );
}
コード例 #20
0
BOOL _ApplyPreviewBlock(HWND hwnd, char themeFile[], char szCBZBase[], char szShare[], char szClass[], int index)
{
    PSFRAMESHARE *pFrameShare;
    PLUGIN_LIST List;
    HMODULE hMod;
    PAPPLYFN pApplyFn;
    PINITFN pInitFn;
    char szError[CCHMAXPATH];
    char szProfile[CCHMAXPATH + 1];
    char szFile[CCHMAXPATH + 1];
    char szSaveName[CCHMAXPATH + 1];
    char szPluginBase[CCHMAXPATH + 1];
    char *tempPtr;
    int i, j;
    PSTBDATA *pTBData;
    HINI hIni;
    PDESTROYFN pDestroyFn;
    ULONG ulDataOffset;

//    if (DosGetNamedSharedMem((PPVOID) & pFrameShare, PSFRAME_SHARE, PAG_READ) != NO_ERROR)
    {
        PSUTErrorFunc(NULLHANDLE, "Error", "Couldn't get Shared Memory", szFile, 0UL);
        return FALSE;
    }
    ulDataOffset = pFrameShare->ulDataOffset + index * sizeof(void *);
    DosFreeMem(pFrameShare);

    if ((pTBData = WinQueryWindowPtr(hwnd, ulDataOffset)) == NULL)
    {
        PSUTErrorFunc(NULLHANDLE, "Error", "Couldn't get Window Data", szFile, 0UL);
        return FALSE;
    }

    // get profile name
    if (!PrfQueryProfileString(HINI_USERPROFILE,
                               "CandyBarZ",
                               "Profile",
                               NULL,
                               szFile,
                               CCHMAXPATH))
        return FALSE;
    if ((hIni = PrfOpenProfile(WinQueryAnchorBlock(hwnd), szFile)) == NULLHANDLE)
        return FALSE;

    // free plugin resources
    for (i = 0; i < pTBData->cbPlugins; i++)
    {
        //Query The Plugin's CBZInit Function
        if (DosQueryProcAddr(pTBData->Plugins[i].hModDll, 0, "CBZDestroy",
                             (PFN *) & (pDestroyFn)) == NO_ERROR)
        {
            //Call the plugins destroy function.
            pDestroyFn(pTBData->Plugins[i].pData);
        }

        if (pTBData->Plugins[i].hModDll != NULLHANDLE)
            DosFreeModule(pTBData->Plugins[i].hModDll);
    }

    if (!runParser(themeFile, szClass, &List, szError))
    {
        PSUTErrorFunc(NULLHANDLE, "Error", "ApplyPreviewBlock", szError, 0UL);
        PrfCloseProfile(hIni);
        return FALSE;
    }

    strcpy(szPluginBase, szCBZBase);
    strcat(szPluginBase, "plugins\\");

    //update the windows memory.
    pTBData->cbPlugins = List.cbPlugins;

    //fill in ptb2 structure.
    for (i = 0; i < (pTBData->cbPlugins); i++)
    {
        //Initialize to some initial values...
        pTBData->Plugins[i].bActiveEnabled = TRUE;
        pTBData->Plugins[i].bInactiveEnabled = TRUE;
        pTBData->Plugins[i].pData = NULL;
        pTBData->Plugins[i].cbData = 0;

        //copy plugin names to shared memory.
        strcpy(pTBData->Plugins[i].szPluginDLL,
               List.pPluginAttributes[i].szPluginName);

        _makepath(szFile, NULL, szPluginBase, pTBData->Plugins[i].szPluginDLL, "DLL");
        //Load the Plugin Module
        if (DosLoadModule(szError, sizeof(szError), szFile,
                          &(pTBData->Plugins[i].hModDll)) != NO_ERROR)
        {
            //Error loading the dll...disable this plugin!
            pTBData->Plugins[i].bActiveEnabled = FALSE;
            pTBData->Plugins[i].bInactiveEnabled = FALSE;
            continue;           //end this iteration...try next plugin.

        }

        //Query The Plugin's CBZPluginDataSize Function
        if (DosQueryProcAddr(pTBData->Plugins[i].hModDll, 0, "CBZInit",
                             (PFN *) & (pInitFn)) != NO_ERROR)
        {
            //error in Plugin's initialization...disable the plugin!
            pTBData->Plugins[i].bActiveEnabled = FALSE;
            pTBData->Plugins[i].bInactiveEnabled = FALSE;
            DosFreeModule(pTBData->Plugins[i].hModDll);
            continue;           //end this iteration..try next plugin.

        }
        //Call the Plugins Init function.
        if (!pInitFn(hIni, "", szClass, (PVOID *) & (pTBData->Plugins[i].pData)))
        {
            //error in Plugin's initialization...disable the plugin!
            pTBData->Plugins[i].bActiveEnabled = FALSE;
            pTBData->Plugins[i].bInactiveEnabled = FALSE;
            DosFreeModule(pTBData->Plugins[i].hModDll);
            continue;           //end this iteration..try next plugin.

        }

        //Query the Plugin's Window Procedure.
        if (DosQueryProcAddr(pTBData->Plugins[i].hModDll, 0, "CBZPluginWndProc",
                (PFN *) & (pTBData->Plugins[i].pPluginWndProc)) != NO_ERROR)
        {
            //error getting the Plugin's WndProc...disable the plugin!
            pTBData->Plugins[i].bActiveEnabled = FALSE;
            pTBData->Plugins[i].bInactiveEnabled = FALSE;
            DosFreeModule(pTBData->Plugins[i].hModDll);
            DosFreeMem(pTBData->Plugins[i].pData);
            continue;           //end this iteration...try next plugin.

        }

        //Query the address of the plugin's Render function.
        if (DosQueryProcAddr(pTBData->Plugins[i].hModDll, 0, "CBZPluginRender",
               (PFN *) & (pTBData->Plugins[i].pfnPluginRender)) != NO_ERROR)
        {
            //Error getting CBZPluginRender function!
            pTBData->Plugins[i].bActiveEnabled = FALSE;
            pTBData->Plugins[i].bInactiveEnabled = FALSE;
            DosFreeModule(pTBData->Plugins[i].hModDll);
            DosFreeMem(pTBData->Plugins[i].pData);
            continue;           //end this iteration...try next plugin.

        }
    }                           //end active plugin for(..) loop

    for (j = 0; j < List.cbPlugins; j++)
    {

        for (i = 0; i < List.pPluginAttributes[j].cbAttributes; i++)
        {
            //If there is a %CBZBaseDir% in the attribute, replace it with the basePath
            if (strstr(List.pPluginAttributes[j].keyValue[i].value, "%CBZBaseDir%") != NULL)
            {
                //%CBZBaseDir% must be at the start of the string
                //allocate space for the new string
                tempPtr = (char *) malloc(sizeof(char) * (strlen(szCBZBase) + strlen(List.pPluginAttributes[j].keyValue[i].value) - strlen("%CBZBaseDir%") + 1));
                tempPtr[0] = '\0';
                strcat(tempPtr, szCBZBase);
                sscanf(List.pPluginAttributes[j].keyValue[i].value, "%%CBZBaseDir%%\\%s", szProfile);
                strcat(tempPtr, szProfile);
                free(List.pPluginAttributes[j].keyValue[i].value);
                //replace the old string with the new string.
                List.pPluginAttributes[j].keyValue[i].value = tempPtr;
            }
        }

        //plugins might not be in LIBPATH, create full path here.
        _makepath(szFile, NULL, szPluginBase, List.pPluginAttributes[j].szPluginName, "DLL");

        if (DosLoadModule(szError, sizeof(szError), szFile, &hMod) == NO_ERROR)
        {
            if (DosQueryProcAddr(hMod, 0, "CBZApply", (PFN *) & pApplyFn) == NO_ERROR)
            {
                if (pApplyFn == NULL)
                {
                    PSUTErrorFunc(NULLHANDLE, "Error", "ApplyPreviewBlock", "pApplyFn is NULL!", 0UL);
                }

                //check return code from this to make sure it was sucessful.. if not disable the plugin
                pApplyFn(szClass, (List.pPluginAttributes[j].keyValue),
                         List.pPluginAttributes[j].cbAttributes,
                         List.pPluginAttributes[j].enabledState,
                         pTBData->Plugins[j].pData);
            }
            else
            {
                PSUTErrorFunc(NULLHANDLE, "Error", "ApplyPreviewBlock", "Failed Querying Procedure Address for CBZApply", 0UL);
            }
            DosFreeModule(hMod);
        }
        else
        {
            PSUTErrorFunc(NULLHANDLE, "Error", "ApplyPreviewBlock", "Error Querying Plugin Module.. (Missing?)", 0UL);
            pTBData->cbPlugins = j - 1;
            break;
            //disable it here
        }

    }

    //delete all the attributes in the plugin/key/value list
    CBZFreePLUGIN_LIST(&List);

    PrfCloseProfile(hIni);
    return TRUE;
}
コード例 #21
0
int IniFile::read( const char *section, const char *key, const char *deflt,
                   char *buffer, int len )
{
    return( PrfQueryProfileString( _handle, (PSZ)section, (PSZ)key, (PSZ)deflt,
                                   buffer, len ) );
}
コード例 #22
0
ファイル: winstall.c プロジェクト: OS2World/APP-COMM-ComScope
void main(int argc,char *argv[])
  {
  HMQ hmqQueue;
  QMSG qmsgMessage;
  ULONG flCreate;
  LONG lIndex;
  char szString[80];
  int iIndex;
  HFILE hCom;
  APIRET rc;
  ULONG ulAction;
  ULONG cbDataSize = sizeof(ULONG);

  if (argc >= 2)
    {
    for (lIndex = 1;lIndex < argc;lIndex++)
      {
      if ((argv[lIndex][0] == '/') || (argv[lIndex][0] == '-'))
        {
        switch (argv[lIndex][1] & 0xdf)
          {
          case 'X':
            bDebug = TRUE;
            break;
          default:
            strcpy(szDemoPath,&argv[lIndex][1]);
            bInstallDemo = TRUE;
            break;
          }
        }
      }
    }

  stInst.hab = WinInitialize((USHORT)NULL);

  hmqQueue   = WinCreateMsgQueue(stInst.hab,0);

  WinRegisterClass(stInst.hab,
                  "INSTALL",
            (PFNWP)fnwpClient,
                   0L,
                   4);

  DosQuerySysInfo(QSV_MAX_PATH_LENGTH,QSV_MAX_PATH_LENGTH,&stInst.ulMaxPathLen,sizeof(ULONG));

  MemAlloc(&pszPath,((stInst.ulMaxPathLen * 3) + 20));
  MemAlloc(&stInst.paszStrings[CONFIGDDLIBRARYSPEC],(stInst.ulMaxPathLen + 1));
  MemAlloc(&stInst.pszSourceIniPath,(stInst.ulMaxPathLen + 1));
  MemAlloc(&stInst.paszStrings[CURRENTDRIVERSPEC],(stInst.ulMaxPathLen + 1));
  MemAlloc(&stInst.paszStrings[DRIVERINISPEC],(stInst.ulMaxPathLen + 1));
  MemAlloc(&stInst.paszStrings[XFERLIBRARYSPEC],(stInst.ulMaxPathLen + 1));
  MemAlloc(&stInst.pszDLLpath,(stInst.ulMaxPathLen + 1));
  MemAlloc(&stInst.pszAppsPath,(stInst.ulMaxPathLen + 1));
  MemAlloc(&pszUninstallIniPath,(stInst.ulMaxPathLen + 1));
  MemAlloc(&pszCurrentAppsPath,(stInst.ulMaxPathLen + 1));
  MemAlloc(&stInst.pszSourcePath,(stInst.ulMaxPathLen + 1));
  MemAlloc(&pszHelpFileSpec,(stInst.ulMaxPathLen + 1));
  MemAlloc(&stCOMiCFG.pszDriverIniSpec,(stInst.ulMaxPathLen + 1));
  MemAlloc(&stInst.paszStrings[CONFIGAPPLIBRARYSPEC],(stInst.ulMaxPathLen + 1));

  DosQuerySysInfo(QSV_BOOT_DRIVE,QSV_BOOT_DRIVE,&ulBootDrive,sizeof(ULONG));
  stInst.chBootDrive = ('A' + (char)ulBootDrive - 1);

  if (bDebug)
    PrintDebug("Debug Messaging","is enabled");

  if ((rc = DosOpen(SPECIAL_DEVICE,&hCom,&ulAction,0L,0L,0x0001,0x21c2,0L)) == 0)
    {
    if ((GetDriverPath(hCom,pszPath)) && (pszPath[1] == ':'))
      {
      for (iIndex = 0;iIndex < stInst.ulMaxPathLen;iIndex++)
        {
        if (pszPath[iIndex] == ' ')
          break;
        pszPath[iIndex] = toupper(pszPath[iIndex]);
        }

      strcpy(szDriverVersionString,&pszPath[iIndex + 1]);
      szDriverVersionString[strlen(szDriverVersionString) - 3] = 0;
      pszPath[iIndex] = 0;
      strcpy(stInst.paszStrings[CURRENTDRIVERSPEC],pszPath);
      MemAlloc(&stInst.paszStrings[REMOVEOLDDRIVERSPEC],(stInst.ulMaxPathLen + 1));
      strcpy(stInst.paszStrings[REMOVEOLDDRIVERSPEC],pszPath);
      strcpy(stInst.paszStrings[DRIVERINISPEC],pszPath);
      AppendINI(stInst.paszStrings[DRIVERINISPEC]);
      SetEndOfPath(pszPath);
      strcpy(stInst.pszDLLpath,pszPath);
      strcpy(stInst.pszAppsPath,pszPath);
      sprintf(pszUninstallIniPath,"%s\\%s",pszPath,szUninstallIniFileName);
      bCOMiInstalled = TRUE;
      bItemOneLocked = FALSE;
      }
    DosClose(hCom);
    }

  strcpy(stInst.pszSourcePath,argv[0]);
  SetEndOfPath(stInst.pszSourcePath);
  sprintf(pszHelpFileSpec,"%s\\%s",stInst.pszSourcePath,szHelpFileName);

  if (bInstallDemo)
    {
    if (szDemoPath[strlen(szDemoPath) - 1] =='\\')
      szDemoPath[iIndex - 1] = 0;
    strncpy(pszPath,stInst.pszSourcePath,3);
    iIndex = 3;
    if (pszPath[2] != '\\')
      {
      iIndex = 2;
      pszPath[2] = '\\';
      }
    sprintf(&pszPath[3],"%s\\%s",szDemoPath,&stInst.pszSourcePath[iIndex]);
    strcpy(stInst.pszSourcePath,pszPath);
    }

  sprintf(stInst.pszSourceIniPath,"%s\\%s",stInst.pszSourcePath,szIniFileName);
  if (bDebug)
    PrintDebug("Source Ini File",stInst.pszSourceIniPath);

  stInst.bCopyCOMscope = TRUE;
  stInst.bCopyPager = TRUE;
  stInst.bCopyCOMi = TRUE;
  stInst.bCreateObjects = TRUE;
#ifdef this_junk
  stInst.bCopyInstall = TRUE;
  stInst.bCopyUtil = TRUE;
  stInst.bCopyPDR = TRUE;
  stInst.bCopyLibraries = TRUE;
#endif
  hSourceProfile = PrfOpenProfile(stInst.hab,stInst.pszSourceIniPath);

  if (hSourceProfile != 0)
    {
    PrfQueryProfileString(hSourceProfile,"Install","False Start 1",0,szFalseStart1,400);
    PrfQueryProfileString(hSourceProfile,"Install","False Start 2",0,szFalseStart2,400);
    if (!PrfQueryProfileData(hSourceProfile,"Install","bConfigurationOnly",&bConfigurationOnly,&cbDataSize))
      bConfigurationOnly = FALSE;
    PrfQueryProfileString(hSourceProfile,"COMi","Driver","COMDD.SYS",szDDname,18);
    PrfQueryProfileString(hSourceProfile,"COMi","Version",0,szCOMiVersion,60);
    PrfQueryProfileString(hSourceProfile,"COMscope","Version",0,szCOMscopeVersion,60);
    PrfQueryProfileString(hSourceProfile,"Pager","Pager File","PAGERDEF.PAG",szPagerFileName,20);
    PrfQueryProfileString(hSourceProfile,"Pager","Version",0,szAppVersion,60);
    PrfQueryProfileString(hSourceProfile,"Pager","Icon File",0,szAppIconFile,60);
    PrfQueryProfileString(hSourceProfile,"Install","Banner One","for the",szBannerOne,MAX_BANNER);
    PrfQueryProfileString(hSourceProfile,"Install","Banner Two","COMi Device Driver",szBannerTwo,MAX_BANNER);
    PrfQueryProfileString(hSourceProfile,"Install","Title","COMi Device Driver Install",szEXEtitle,60);
    PrfQueryProfileString(hSourceProfile,"Install","DD Name","COMi",szConfigDDname,20);
    PrfQueryProfileString(hSourceProfile,"Install","App Name",0,szConfigAppName,20);
    PrfQueryProfileString(hSourceProfile,"Install","Apps Path","C:\\COMM",szDefaultAppsPath,60);
    PrfQueryProfileString(hSourceProfile,"Install","Libs Path","C:\\COMM",szDefaultDLLpath,60);
    PrfQueryProfileString(hSourceProfile,"Install","Version",0,szInstallVersion,60);
    PrfQueryProfileString(hSourceProfile,"Install","Info File",0,szInfoFileName,20);
    PrfQueryProfileString(hSourceProfile,"Install","Info Caption",0,szInfoCaption,60);
    PrfQueryProfileString(hSourceProfile,"Install","License File",0,szLicenseFileName,20);
    PrfQueryProfileString(hSourceProfile,"Install","License Caption",0,szLicenseCaption,60);
    PrfQueryProfileString(hSourceProfile,"Install","Check Caption One",0,szCheckOneCaption,60);
    PrfQueryProfileString(hSourceProfile,"Install","Check Caption Two",0,szCheckTwoCaption,60);
    PrfQueryProfileString(hSourceProfile,"Install","Check Caption Three",0,szCheckThreeCaption,60);
    PrfQueryProfileString(hSourceProfile,"Install","Check Caption Four",0,szCheckFourCaption,60);
    PrfQueryProfileString(hSourceProfile,"Install","Check Caption Five",0,szCheckFiveCaption,60);
    PrfQueryProfileString(hSourceProfile,"Install","DD Config Help","COMscope.HLP",szConfigDDhelpFileName,60);
    PrfQueryProfileString(hSourceProfile,"Install","App Config Help",0,szConfigAppHelpFileName,60);
    PrfQueryProfileString(hSourceProfile,"Install","DD Config Library",COMi_CONFIG_LIB,szConfigDDlibraryName,60);
    PrfQueryProfileString(hSourceProfile,"Install","DD Config Function","InstallDevice",szConfigDDfunctionName,60);
    PrfQueryProfileString(hSourceProfile,"Install","Transfer Library",COMi_INSTALL_LIB,szTransferLibraryName,60);
    sprintf(stInst.paszStrings[XFERLIBRARYSPEC],"%s\\%s.DLL",stInst.pszSourcePath,szTransferLibraryName);

    PrfQueryProfileString(hSourceProfile,"Install","Transfer Function","TransferFiles",szTransferFunctionName,60);
    PrfQueryProfileString(hSourceProfile,"Install","App Config Library",0,szConfigAppLibraryName,60);
    PrfQueryProfileString(hSourceProfile,"Install","App Config Function",0,szConfigAppFunctionName,60);
    if (!PrfQueryProfileData(hSourceProfile,"COMi","OEM_type",&ulOEMtype,&cbDataSize))
      ulOEMtype = 0;
    if (!PrfQueryProfileData(hSourceProfile,"COMi","Max Device Count",&stCOMiCFG.ulMaxDeviceCount,&cbDataSize))
      stCOMiCFG.ulMaxDeviceCount = 0;
    if (!PrfQueryProfileData(hSourceProfile,"COMscope","ProgramSize",&ulCOMscopeSize,&cbDataSize))
      {
      stInst.bCopyCOMscope = FALSE;
      bCOMscopeToInstall = FALSE;
      }
    if (!PrfQueryProfileData(hSourceProfile,"Pager","ProgramSize",&ulPagerSize,&cbDataSize))
      {
      stInst.bCopyPager = FALSE;
      bPagerToInstall = FALSE;
      }
    if (!PrfQueryProfileData(hSourceProfile,"COMi","ProgramSize",&ulCOMiSize,&cbDataSize))
      {
      stInst.bCopyCOMi = FALSE;
      bCOMiToInstall = FALSE;
      }
    if (!PrfQueryProfileData(hSourceProfile,"Install","ProgramSize",&ulInstallSize,&cbDataSize))
      {
      stInst.bCopyInstall = FALSE;
      bInstallToInstall = FALSE;
      }
    if (!PrfQueryProfileData(hSourceProfile,"Utilities","ProgramSize",&ulUtilSize,&cbDataSize))
      {
      stInst.bCopyUtil = FALSE;
      bUtilToInstall = FALSE;
      }
    if (!PrfQueryProfileData(hSourceProfile,"PDR","ProgramSize",&ulPDRsize,&cbDataSize))
      {
      stInst.bCopyPDR = FALSE;
      bPDRtoInstall = FALSE;
      }
    if (!PrfQueryProfileData(hSourceProfile,"Libraries","ProgramSize",&ulLibsSize,&cbDataSize))
      {
      stInst.bCopyLibraries = FALSE;
      bLibrariesToInstall = FALSE;
      }
    if (!stInst.bCopyCOMscope)
      stInst.bCopyInstall = TRUE;
    }
  else
    exit(55);

  if (!bCOMiInstalled)
    {
    if (strlen(szFalseStart1) != 0)
      bFalseStart = TRUE;
    else
      {
      if (PrfQueryProfileString(HINI_USERPROFILE,szConfigDDname,"Initialization",0L,
                                                         pszPath,
                                                         stInst.ulMaxPathLen) != 0)
        {
        strcpy(stInst.pszAppsPath,pszPath);
        SetEndOfPath(stInst.pszAppsPath);
        sprintf(pszUninstallIniPath,"%s\\%s",stInst.pszAppsPath,szUninstallIniFileName);
        bPreviousInstallation = TRUE;
        }
      else
        {
        strcpy(stInst.pszAppsPath,szDefaultAppsPath);
        stInst.pszAppsPath[0] = stInst.chBootDrive;
        sprintf(pszUninstallIniPath,"%s\\%s",stInst.pszAppsPath,szUninstallIniFileName);
        strcpy(stInst.pszDLLpath,szDefaultDLLpath);
        stInst.pszDLLpath[0] = stInst.chBootDrive;
        sprintf(pszPath,"%s\\%s",stInst.pszAppsPath,szDDname);
        }
  //    strcpy(stInst.paszStrings[CURRENTDRIVERSPEC],pszPath);
      strcpy(stInst.paszStrings[DRIVERINISPEC],pszPath);
      AppendINI(stInst.paszStrings[DRIVERINISPEC]);
      }
    }

  strcpy(stCOMiCFG.pszDriverIniSpec,stInst.paszStrings[DRIVERINISPEC]);

  if (strlen(pszUninstallIniPath) != 0)
    {
    if (DosQueryPathInfo(pszUninstallIniPath,1,&stFileStatus,sizeof(FILESTATUS3)) == NO_ERROR)
      {
      if ((hInstalledProfile = PrfOpenProfile(stInst.hab,pszUninstallIniPath)) != 0)
        {
        if (PrfQueryProfileString(hInstalledProfile,"Installed","Program Path",0,pszPath,stInst.ulMaxPathLen))
          {
          strcpy(pszCurrentAppsPath,pszPath);
          bUninstall = TRUE;
          }
        if (PrfQueryProfileString(hInstalledProfile,"Installed","Library Path",0,pszPath,stInst.ulMaxPathLen))
          strcpy(stInst.pszDLLpath,pszPath);
        else
          strcpy(stInst.pszDLLpath,stInst.pszAppsPath);
        PrfCloseProfile(hInstalledProfile);
        }
      }
    }

  stInst.cbSize = sizeof(INSTALL);
  sprintf(stInst.paszStrings[CONFIGDDLIBRARYSPEC],"%s\\%s.DLL",stInst.pszSourcePath,szConfigDDlibraryName);
  stCOMiCFG.byOEMtype = (BYTE)ulOEMtype;

  flCreate = (FCF_BORDER | FCF_ACCELTABLE | FCF_TASKLIST | FCF_MENU | FCF_TITLEBAR | FCF_SYSMENU);

  stInst.hwndFrame = WinCreateStdWindow(HWND_DESKTOP,
                                 0L,
                                &flCreate,
                                "INSTALL",
                                 NULL,
                                 WS_CLIPCHILDREN,
                        (HMODULE)NULL,
                                 WIN_INSTALL,
                                &hwndClient);

  WinSetWindowText(stInst.hwndFrame,szEXEtitle);
  SetInitialPosition(stInst.hwndFrame);
  WinShowWindow(stInst.hwndFrame,TRUE);
  WinSetFocus(HWND_DESKTOP,hwndClient);

  if (strlen(szConfigAppName) == 0)
    {
    WinSendMsg(WinWindowFromID(stInst.hwndFrame,FID_MENU),MM_REMOVEITEM,MPFROM2SHORT(IDM_CONFIG_APP,TRUE),(MPARAM)0);
#ifdef this_junk
    bItemThreeLocked = TRUE;
    InsertAppMenu();
    MenuItemEnable(stInst.hwndFrame,IDM_CONFIG_APP,FALSE);
#endif
    }

  if ((hwndInstallHelpInstance = HelpInit(pszHelpFileSpec,szHelpWindowTitle)) == 0)
    {
    MenuItemEnable(stInst.hwndFrame,IDM_HELPINDEX,FALSE);
    MenuItemEnable(stInst.hwndFrame,IDM_HELPEXTEND,FALSE);
    MenuItemEnable(stInst.hwndFrame,IDM_HELPKEYS,FALSE);
    MenuItemEnable(stInst.hwndFrame,IDM_HELPFORHELP,FALSE);
    }

  while(WinGetMsg(stInst.hab,&qmsgMessage,(HWND)NULL,0,0))
    WinDispatchMsg(stInst.hab,&qmsgMessage);

  DestroyHelpInstance(hwndInstallHelpInstance);

  if (hConfigProfile != 0)
    PrfCloseProfile(hConfigProfile);
  if (hSourceProfile != 0)
    PrfCloseProfile(hSourceProfile);

  MemFree(pszPath);
  MemFree(stInst.paszStrings[XFERLIBRARYSPEC]);
  MemFree(stInst.paszStrings[CONFIGDDLIBRARYSPEC]);
  MemFree(stCOMiCFG.pszRemoveOldDriverSpec);
  MemFree(stInst.pszSourceIniPath);
  if (stInst.paszStrings[REMOVEOLDDRIVERSPEC] != NULL)
    MemFree(stInst.paszStrings[REMOVEOLDDRIVERSPEC]);
  MemFree(stInst.paszStrings[CURRENTDRIVERSPEC]);
  MemFree(stInst.paszStrings[DRIVERINISPEC]);
  MemFree(stInst.pszDLLpath);
  MemFree(stInst.pszAppsPath);
  MemFree(pszUninstallIniPath);
  MemFree(pszCurrentAppsPath);
  MemFree(stInst.pszSourcePath);
  MemFree(pszHelpFileSpec);
  MemFree(stCOMiCFG.pszDriverIniSpec);

  WinDestroyWindow(stInst.hwndFrame);
  WinDestroyMsgQueue(hmqQueue);
  WinTerminate(stInst.hab);
  exit(0);
  }
コード例 #23
0
/*--------------------------------------------------------------------------------------*\
 * Procedure opens the profile and reads the UPS structure from.                        *
 * Req:                                                                                 *
 *      pHini ......... A pointer to the handle of the profile                          *
 *      pHab .......... A pointer to extract the anchor block of the window             *
 *      pUps .......... A pointer to the UPS structure                                  *
 * Returns:                                                                             *
 *      TRUE/FALSE .... If called sucessfully/unsucessfully                             *
\*--------------------------------------------------------------------------------------*/
BOOL    Read_Profile(HINI *pHini, HAB *pHab, UPS *pUps)
{
ULONG   ulSize;
UCHAR   *uc='\0';
                                        /* First open the profile */
*pHini=PrfOpenProfile(*pHab, pucSD2Profile);
while(TRUE)
    {
    ulSize=sizeof(UCHAR);
    if(PrfQueryProfileData(             /* Query binary data from profile */
        *pHini,                         /* Handle of profile */
        SD2_CLASSNAME,                  /* Application name */
        "IDUBC_Hours",                  /* Key name */
        &pUps->IDUBC_Hours,             /* Value data */
        &ulSize)==FALSE)                /* Size of value data */
        { *pHini=NULLHANDLE; break; }
    if(PrfQueryProfileData(
        *pHini,
        SD2_CLASSNAME,
        "IDUBC_Minutes",
        &pUps->IDUBC_Minutes,
        &ulSize)==FALSE) { *pHini=NULLHANDLE; break; }
    if(PrfQueryProfileData(
        *pHini,
        SD2_CLASSNAME,
        "IDUAS_Hours",
        &pUps->IDUAS_Hours,
        &ulSize)==FALSE) { *pHini=NULLHANDLE; break; }
    if(PrfQueryProfileData(
        *pHini,
        SD2_CLASSNAME,
        "IDUAS_Minutes",
        &pUps->IDUAS_Minutes,
        &ulSize)==FALSE) { *pHini=NULLHANDLE; break; }
    if(PrfQueryProfileData(
        *pHini,
        SD2_CLASSNAME,
        "IDUASD_Hours",
        &pUps->IDUASD_Hours,
        &ulSize)==FALSE) { *pHini=NULLHANDLE; break; }
    if(PrfQueryProfileData(
        *pHini,
        SD2_CLASSNAME,
        "IDUASD_Minutes",
        &pUps->IDUASD_Minutes,
        &ulSize)==FALSE) { *pHini=NULLHANDLE; break; }
    if(PrfQueryProfileData(
        *pHini,
        SD2_CLASSNAME,
        "IDUS_Hours",
        &pUps->IDUS_Hours,
        &ulSize)==FALSE) { *pHini=NULLHANDLE; break; }
    if(PrfQueryProfileData(
        *pHini,
        SD2_CLASSNAME,
        "IDUS_Minutes",
        &pUps->IDUS_Minutes,
        &ulSize)==FALSE) { *pHini=NULLHANDLE; break; }
    ulSize=sizeof(ULONG);
    if(PrfQueryProfileData(
        *pHini,
        SD2_CLASSNAME,
        "GRP_Mode",
        &pUps->GRP_Mode,
        &ulSize)==FALSE) { *pHini=NULLHANDLE; break; }
    ulSize=sizeof(Ups.IDS_PgmName);
    if(PrfQueryProfileString(
        *pHini,
        SD2_CLASSNAME,
        "IDS_PgmName",
        uc,
        pUps->IDS_PgmName,
        ulSize)==FALSE) { *pHini=NULLHANDLE; break; }
    if(PrfQueryProfileString(
        *pHini,
        SD2_CLASSNAME,
        "IDS_PgmDirectory",
        uc,
        pUps->IDS_PgmDirectory,
        ulSize)==FALSE) { *pHini=NULLHANDLE; break; }
    if(PrfQueryProfileString(
        *pHini,
        SD2_CLASSNAME,
        "IDS_PgmInputs",
        uc,
        pUps->IDS_PgmInputs,
        ulSize)==FALSE) { *pHini=NULLHANDLE; break; }
    ulSize=sizeof(Ups.IDS_UserInfo);
    if(PrfQueryProfileString(
        *pHini,
        SD2_CLASSNAME,
        "IDS_UserInfo",
        uc,
        pUps->IDS_UserInfo,
        ulSize)==FALSE) { *pHini=NULLHANDLE; break; }
    return(PrfCloseProfile(*pHini));    /* Close and return result */
    }
if(*pHini==NULLHANDLE)
    {
                                        /* SHUTDOWN.INI missing logging into logfile */
    DosGetDateTime(&UPS_Current);
    UPS_LogfileIO(LF_INIFILE_MISSING, MPFROMP(&UPS_Current));
    pUps->IDUBC_Hours=0;                /* Assume default values */
    pUps->IDUBC_Minutes=10;
    pUps->IDUAS_Hours=0;
    pUps->IDUAS_Minutes=1;
    pUps->IDUASD_Hours=0;
    pUps->IDUASD_Minutes=4;
    pUps->IDUS_Hours=0;
    pUps->IDUS_Minutes=7;
    pUps->GRP_Mode=IDM_LPT1;
    strcpy(pUps->IDS_PgmName, "CMD.EXE");
    strcpy(pUps->IDS_PgmDirectory, "");
    strcpy(pUps->IDS_PgmInputs, "");
    strcpy(pUps->IDS_UserInfo, "An error occured accessing SHUTDOWN.INI, please correct "\
        "as soon as possible!");
    return(FALSE);
    }
}
コード例 #24
0
ファイル: page.c プロジェクト: OS2World/APP-COMM-ComScope
BOOL APIENTRY InstallPager(INSTALL *pstInst)
  {
  int iIndex;
  int iCountPos;
  int iDestPathEnd;
  int iSourcePathEnd;
  APIRET rc;
  BOOL bSuccess = TRUE;
  HPOINTER hPointer;
//  int iLen;
  int iFileCount;
  int iObjectCount;
  int iEnd;
  HOBJECT hObject;
  HOBJECT *phObject;
  BOOL bObjectBad;
  unsigned int uiAttrib;
  ULONG ulFileCount;
  ULONG cbDataSize = sizeof(ULONG);
  HINI hInstalledProfile;
  HINI hSourceProfile;

  hSourceProfile = PrfOpenProfile(pstInst->hab,pstInst->pszSourceIniPath);
  iEnd = sprintf(szFileNumber,"File_");
  strcpy(szDestSpec,pstInst->pszAppsPath);
  iDestPathEnd = strlen(szDestSpec);
  szDestSpec[iDestPathEnd++] = '\\';
  szDestSpec[iDestPathEnd] = 0;
  hPointer = WinQuerySysPointer(HWND_DESKTOP,SPTR_WAIT,FALSE);
  WinSetPointer(HWND_DESKTOP,hPointer);

  strcpy(szSourceSpec,pstInst->pszSourcePath);
  iSourcePathEnd = strlen(szSourceSpec);
  szSourceSpec[iSourcePathEnd++] = '\\';

  szPagerEXEname[0] = 0;
  szInstallEXEname[0] = 0;

  sprintf(szInstalledIniPath,"%s%s",szDestSpec,pstInst->paszStrings[UNINSTALLINIFILENAME]);
  if (!MakePath(pstInst->hwndFrame,pstInst->pszAppsPath))
   return(FALSE);
  hInstalledProfile = PrfOpenProfile(pstInst->hab,szInstalledIniPath);
  cbDataSize = sizeof(ULONG);
  if (!PrfQueryProfileData(hInstalledProfile,"Installed","Files",&iFileCount,&cbDataSize))
    iFileCount = 0;
  if (!PrfQueryProfileData(hInstalledProfile,"Installed","Objects",&iObjectCount,&cbDataSize))
    iObjectCount = 0;
  sprintf(szPath,"%c:\\DELLOCKS.CMD",pstInst->chBootDrive);
  DosForceDelete(szPath);
  if (pstInst->bCopyCOMi)
    {
    strcpy(szDestSpec,pstInst->pszAppsPath);
    iDestPathEnd = strlen(szDestSpec);
    szDestSpec[iDestPathEnd++] = '\\';
    szDestSpec[iDestPathEnd] = 0;
    sprintf(pstInst->paszStrings[DRIVERINISPEC],"%s\\%s",pstInst->pszAppsPath,pstInst->paszStrings[DDNAME]);
    if (strlen(pstInst->paszStrings[CURRENTDRIVERSPEC]) != 0)
      {
      if (strcmp(pstInst->paszStrings[CURRENTDRIVERSPEC],pstInst->paszStrings[DRIVERINISPEC]) != 0)
        {
        strcpy(szPath,pstInst->paszStrings[DDNAME]);
        AppendINI(szPath);
        sprintf(szFileName,"Existing %s",szPath);
        if (pstInst->paszStrings[REMOVEOLDDRIVERSPEC] != NULL)
          strcpy(pstInst->paszStrings[REMOVEOLDDRIVERSPEC],pstInst->paszStrings[CURRENTDRIVERSPEC]);
        AppendINI(pstInst->paszStrings[DRIVERINISPEC]);
        AppendINI(pstInst->paszStrings[CURRENTDRIVERSPEC]);
        pstInst->pfnPrintProgress(szFileName,pstInst->paszStrings[DRIVERINISPEC]);
        if (pstInst->bSavedDriverIniFile)
          {
          sprintf(pstInst->paszStrings[CURRENTDRIVERSPEC],"%c:\\COMDDINI.OLD",pstInst->chBootDrive);
          DosCopy(pstInst->paszStrings[CURRENTDRIVERSPEC],pstInst->paszStrings[DRIVERINISPEC],DCPY_EXISTING);
          pstInst->bSavedDriverIniFile = FALSE;
          if (pstInst->fCurrentIni != UNINSTALL_SAVE_INI)
            DosDelete(pstInst->paszStrings[CURRENTDRIVERSPEC]);
          }
        else
          if (DosCopy(pstInst->paszStrings[CURRENTDRIVERSPEC],pstInst->paszStrings[DRIVERINISPEC],DCPY_EXISTING) != NO_ERROR)
            {
            sprintf(pstInst->paszStrings[CURRENTDRIVERSPEC],"%c:\\COMDDINI.OLD",pstInst->chBootDrive);
            DosCopy(pstInst->paszStrings[CURRENTDRIVERSPEC],pstInst->paszStrings[DRIVERINISPEC],DCPY_EXISTING);
            DosForceDelete(pstInst->paszStrings[CURRENTDRIVERSPEC]);
            }
        }
      else
        {
        rc = DosQueryPathInfo(pstInst->paszStrings[CURRENTDRIVERSPEC],1,&stFileStatus,sizeof(FILESTATUS3));
        if ((rc == ERROR_PATH_NOT_FOUND) || (rc == ERROR_FILE_NOT_FOUND))
          {
          sprintf(pstInst->paszStrings[CURRENTDRIVERSPEC],"%c:\\COMDDINI.OLD",pstInst->chBootDrive);
          DosCopy(pstInst->paszStrings[CURRENTDRIVERSPEC],pstInst->paszStrings[DRIVERINISPEC],DCPY_EXISTING);
          DosForceDelete(pstInst->paszStrings[CURRENTDRIVERSPEC]);
          }
        }
      }
    else
      {
      AppendINI(pstInst->paszStrings[DRIVERINISPEC]);
      rc = DosQueryPathInfo(pstInst->paszStrings[DRIVERINISPEC],1,&stFileStatus,sizeof(FILESTATUS3));
      if ((rc == ERROR_PATH_NOT_FOUND) || (rc == ERROR_FILE_NOT_FOUND))
        {
        sprintf(szPath,"%c:\\COMDDINI.OLD",pstInst->chBootDrive);
        DosCopy(szPath,pstInst->paszStrings[DRIVERINISPEC],DCPY_EXISTING);
        DosForceDelete(szPath);
        }
      }
    AppendINI(pstInst->paszStrings[DRIVERINISPEC]);
    sprintf(&szDestSpec[iDestPathEnd],"%s",pstInst->paszStrings[DDNAME]);
    sprintf(&szSourceSpec[iSourcePathEnd],"%s",pstInst->paszStrings[DDNAME]);
    pstInst->pfnPrintProgress(pstInst->paszStrings[DDNAME],szDestSpec);
    if ((rc = DosCopy(szSourceSpec,szDestSpec,DCPY_EXISTING)) != NO_ERROR)
      {
      bSuccess = FALSE;
      if (!DisplayCopyError(pstInst->paszStrings[DDNAME],szDestSpec,rc))
        goto gtFreePathMem;
      }
    ClearReadOnly(szDestSpec);
    itoa(++iFileCount,&szFileNumber[iEnd],10);
    PrfWriteProfileString(hInstalledProfile,"Installed",szFileNumber,szDestSpec);
    AppendINI(szSourceSpec);
    if (DosQueryPathInfo(szSourceSpec,FIL_STANDARD,&stFileStatus,sizeof(FILESTATUS3)) == NO_ERROR)
      {
      AppendINI(szDestSpec);
      strcpy(szPath,pstInst->paszStrings[DDNAME]);
      AppendINI(szPath);
      pstInst->pfnPrintProgress(szPath,szDestSpec);
      DosCopy(szSourceSpec,szDestSpec,DCPY_EXISTING);
      ClearReadOnly(szDestSpec);
      itoa(++iFileCount,&szFileNumber[iEnd],10);
      PrfWriteProfileString(hInstalledProfile,"Installed",szFileNumber,szDestSpec);
      }
    strcpy(szFileKey,"File_");
    iCountPos = strlen(szFileKey);
    ulFileCount = 0;
    PrfQueryProfileData(hSourceProfile,"COMi","Files",&ulFileCount,&cbDataSize);
    for (iIndex = 1;iIndex <= ulFileCount;iIndex++)
      {
      itoa(iIndex,&szFileKey[iCountPos],10);
      if (PrfQueryProfileString(hSourceProfile,"COMi",szFileKey,0,szFileName,18) != 0)
        {
        if (iIndex == 1)
          strcpy(szCOMiINFname,szFileName);
        strcpy(&szDestSpec[iDestPathEnd],szFileName);
        strcpy(&szSourceSpec[iSourcePathEnd],szFileName);
        pstInst->pfnPrintProgress(szFileName,szDestSpec);
        if ((rc = DosCopy(szSourceSpec,szDestSpec,DCPY_EXISTING)) != NO_ERROR)
          {
          bSuccess = FALSE;
          if (!DisplayCopyError(szFileName,szDestSpec,rc))
            goto gtFreePathMem;
          }
        ClearReadOnly(szDestSpec);
        itoa(++iFileCount,&szFileNumber[iEnd],10);
        PrfWriteProfileString(hInstalledProfile,"Installed",szFileNumber,szDestSpec);
        }
      }
    MenuItemEnable(pstInst->hwndFrame,IDM_SETUP,TRUE);
    /*
    ** This entry must be placed here so the the Configuration DLL can "find" the
    ** COMi initialization file, before the device driver is actually loaded.
    */
    PrfWriteProfileString(HINI_USERPROFILE,pstInst->paszStrings[CONFIGDDNAME],"Initialization",pstInst->paszStrings[DRIVERINISPEC]);
    PrfWriteProfileString(HINI_USERPROFILE,pstInst->paszStrings[CONFIGDDNAME],"Version",pstInst->paszStrings[COMIVERSION]);
    }
  if (pstInst->bCopyPager)
    {
    bCopyLibraries = TRUE;
    szPagerEXEname[0] = 0;
    strcpy(szDestSpec,pstInst->pszAppsPath);
    iDestPathEnd = strlen(szDestSpec);
    szDestSpec[iDestPathEnd++] = '\\';
    szDestSpec[iDestPathEnd] = 0;
    strcpy(szFileKey,"File_");
    iCountPos = strlen(szFileKey);
    ulFileCount = 0;
    PrfQueryProfileData(hSourceProfile,"Pager","Files",&ulFileCount,&cbDataSize);
    for (iIndex = 1;iIndex <= ulFileCount;iIndex++)
      {
      itoa(iIndex,&szFileKey[iCountPos],10);
      if (PrfQueryProfileString(hSourceProfile,"Pager",szFileKey,0,szFileName,18) != 0)
        {
        if (iIndex == 1)
          strcpy(szPagerEXEname,szFileName);
        strcpy(&szDestSpec[iDestPathEnd],szFileName);
        strcpy(&szSourceSpec[iSourcePathEnd],szFileName);
        pstInst->pfnPrintProgress(szFileName,szDestSpec);
        if (!CopyFile(szSourceSpec,szDestSpec))
          {
          bSuccess = FALSE;
          if (!DisplayCopyError(szFileName,szDestSpec,rc))
            goto gtFreePathMem;
          }
        itoa(++iFileCount,&szFileNumber[iEnd],10);
        PrfWriteProfileString(hInstalledProfile,"Installed",szFileNumber,szDestSpec);
        }
      }
    PrfWriteProfileString(HINI_USERPROFILE,pstInst->paszStrings[CONFIGAPPNAME],"Version",pstInst->paszStrings[APPVERSION]);
    }
  if (pstInst->bCopyUtil)
    {
    strcpy(szDestSpec,pstInst->pszAppsPath);
    iDestPathEnd = strlen(szDestSpec);
    szDestSpec[iDestPathEnd++] = '\\';
    szDestSpec[iDestPathEnd] = 0;
    strcpy(szFileKey,"File_");
    iCountPos = strlen(szFileKey);
    ulFileCount = 0;
    PrfQueryProfileData(hSourceProfile,"Utilities","Files",&ulFileCount,&cbDataSize);
    for (iIndex = 1;iIndex <= ulFileCount;iIndex++)
      {
      itoa(iIndex,&szFileKey[iCountPos],10);
      if (PrfQueryProfileString(hSourceProfile,"Utilities",szFileKey,0,szFileName,18) != 0)
        {
        strcpy(&szDestSpec[iDestPathEnd],szFileName);
        strcpy(&szSourceSpec[iSourcePathEnd],szFileName);
        pstInst->pfnPrintProgress(szFileName,szDestSpec);
        if ((rc = DosCopy(szSourceSpec,szDestSpec,DCPY_EXISTING)) != NO_ERROR)
          {
          bSuccess = FALSE;
          if (!DisplayCopyError(szFileName,szDestSpec,rc))
            goto gtFreePathMem;
          }
        ClearReadOnly(szDestSpec);
        itoa(++iFileCount,&szFileNumber[iEnd],10);
        PrfWriteProfileString(hInstalledProfile,"Installed",szFileNumber,szDestSpec);
        }
      }
    }
  if (pstInst->bCopyInstall)
    {
    bCopyLibraries = TRUE;
    szInstallEXEname[0] = 0;
    strcpy(szDestSpec,pstInst->pszAppsPath);
    iDestPathEnd = strlen(szDestSpec);
    szDestSpec[iDestPathEnd++] = '\\';
    szDestSpec[iDestPathEnd] = 0;
    sprintf(&szDestSpec[iDestPathEnd],pstInst->paszStrings[INIFILENAME]);
    strcpy(&szSourceSpec[iSourcePathEnd],pstInst->paszStrings[INIFILENAME]);
    PrfCloseProfile(hSourceProfile);
    DosCopy(szSourceSpec,szDestSpec,DCPY_EXISTING);
    ClearReadOnly(szDestSpec);
    hSourceProfile = PrfOpenProfile(pstInst->hab,pstInst->pszSourceIniPath);
    itoa(++iFileCount,&szFileNumber[iEnd],10);
    PrfWriteProfileString(hInstalledProfile,"Installed",szFileNumber,szDestSpec);
    strcpy(szFileKey,"File_");
    iCountPos = strlen(szFileKey);
    ulFileCount = 0;
    PrfQueryProfileData(hSourceProfile,"Install","Files",&ulFileCount,&cbDataSize);
    for (iIndex = 1;iIndex <= ulFileCount;iIndex++)
      {
      itoa(iIndex,&szFileKey[iCountPos],10);
      if (PrfQueryProfileString(hSourceProfile,"Install",szFileKey,0,szFileName,18) != 0)
        {
        if (iIndex == 1)
          strcpy(szInstallEXEname,szFileName);
        strcpy(&szDestSpec[iDestPathEnd],szFileName);
        strcpy(&szSourceSpec[iSourcePathEnd],szFileName);
        pstInst->pfnPrintProgress(szFileName,szDestSpec);
        if (!CopyFile(szSourceSpec,szDestSpec))
          {
//          bSuccess = FALSE;
          if (!DisplayCopyError(szFileName,szDestSpec,rc))
            goto gtFreePathMem;
          }
        itoa(++iFileCount,&szFileNumber[iEnd],10);
        PrfWriteProfileString(hInstalledProfile,"Installed",szFileNumber,szDestSpec);
        }
      }
    }
  PrfWriteProfileString(hInstalledProfile,"Installed","Program Path",pstInst->pszAppsPath);
  PrfWriteProfileData(hInstalledProfile,"Installed","Files",&iFileCount,sizeof(int));
  if (strlen(pstInst->paszStrings[CONFIGDDLIBRARYNAME]) != 0)
    {
    sprintf(pstInst->paszStrings[CONFIGAPPLIBRARYSPEC],"%s\\%s",pstInst->pszAppsPath,pstInst->paszStrings[CONFIGDDLIBRARYNAME]);
    PrfWriteProfileString(HINI_USERPROFILE,pstInst->paszStrings[CONFIGDDNAME],"Configuration",pstInst->paszStrings[CONFIGAPPLIBRARYSPEC]);
    }
  if (strlen(pstInst->paszStrings[CONFIGDDHELPFILENAME]) != 0)
    {
    sprintf(szPath,"%s\\%s",pstInst->pszAppsPath,pstInst->paszStrings[CONFIGDDHELPFILENAME]);
    PrfWriteProfileString(HINI_USERPROFILE,pstInst->paszStrings[CONFIGDDNAME],"Help",szPath);
    }
  if (strlen(pstInst->paszStrings[CONFIGAPPLIBRARYNAME]) != 0)
    {
    sprintf(pstInst->paszStrings[CONFIGAPPLIBRARYSPEC],"%s\\%s",pstInst->pszAppsPath,pstInst->paszStrings[CONFIGAPPLIBRARYNAME]);
    PrfWriteProfileString(HINI_USERPROFILE,pstInst->paszStrings[CONFIGAPPNAME],"Configuration",pstInst->paszStrings[CONFIGAPPLIBRARYSPEC]);
    }
  if (strlen(pstInst->paszStrings[CONFIGAPPHELPFILENAME]) != 0)
    {
    sprintf(szPath,"%s\\%s",pstInst->pszAppsPath,pstInst->paszStrings[CONFIGAPPHELPFILENAME]);
    PrfWriteProfileString(HINI_USERPROFILE,pstInst->paszStrings[CONFIGAPPNAME],"Help",szPath);
    }
  pstInst->bFilesCopied = TRUE;
  MenuItemEnable(pstInst->hwndFrame,IDM_SETUP,TRUE);

  if (pstInst->bCreateObjects)
    {
    bObjectBad = FALSE;
    strcpy(szFileNumber,"Object_");
    iEnd = strlen(szFileNumber);
    hObject = WinCreateObject("WPFolder",szFolderName,szFolderSetup,"<WP_DESKTOP>",CO_UPDATEIFEXISTS);
    if (hObject == 0)
      {
      sprintf(&szFolderName[strlen(szFolderName)],":1");
      hObject = WinCreateObject("WPFolder",szFolderName,szFolderSetup,"<WP_DESKTOP>",CO_UPDATEIFEXISTS);
      }
    if (hObject != 0)
      {
      itoa(++iObjectCount,&szFileNumber[iEnd],10);
      PrfWriteProfileData(hInstalledProfile,"Installed",szFileNumber,&hObject,sizeof(HOBJECT));
      szDestSpec[iDestPathEnd - 1] = 0;
      sprintf(szPath,"<%s>",szFolderName);
      strcpy(szFolderName,szPath);
      if (szCOMiINFname[0] != 0)
        {
        sprintf(szSetupString,"%sEXENAME=VIEW.EXE;PARAMETERS=%s\\%s",szINFobjectSetup,szDestSpec,pstInst->paszStrings[CONFIGDDNAME]);
        sprintf(szObjectName,"%s Users Guide",pstInst->paszStrings[CONFIGDDNAME]);
        hObject = WinCreateObject("WPProgram",szObjectName,szSetupString,szFolderID,CO_UPDATEIFEXISTS);
        if (hObject != 0)
          {
          itoa(++iObjectCount,&szFileNumber[iEnd],10);
          PrfWriteProfileData(hInstalledProfile,"Installed",szFileNumber,&hObject,sizeof(HOBJECT));
          }
        else
          bObjectBad = TRUE;
        }
      if (szPagerEXEname[0] != 0)
        {
        iEnd = sprintf(szSetupString,"%sEXENAME=%s\\%s;STARTUPDIR=%s;ASSOCFILTER=*.PAG;PARAMETERS=% /MSG:\"[Message: ]\" /CFG:\"%*\"",szProgramObjectSetup,szDestSpec,szPagerEXEname,szDestSpec);
        if (strlen(pstInst->paszStrings[APPICONFILE]) != 0)
          sprintf(&szSetupString[iEnd],";ICON=%s\\%s",pstInst->pszAppsPath,pstInst->paszStrings[APPICONFILE]);
        strcat(szObjectName,"Drop");
        hObject = WinCreateObject("WPProgram",szObjectName,szSetupString,szFolderID,CO_UPDATEIFEXISTS);
        if (hObject != 0)
          {
          itoa(++iObjectCount,&szFileNumber[iEnd],10);
          PrfWriteProfileData(hInstalledProfile,"Installed",szFileNumber,&hObject,sizeof(HOBJECT));
          }
        else
          bObjectBad = TRUE;
        }
      if (szInstallEXEname[0] != 0)
        {
        sprintf(szSetupString,"%sEXENAME=%s\\%s;STARTUPDIR=%s",szProgramObjectSetup,szDestSpec,szInstallEXEname,szDestSpec);
        hObject = WinCreateObject("WPProgram","OS/tools Install",szSetupString,szFolderID,CO_UPDATEIFEXISTS);
        if (hObject != 0)
          {
          itoa(++iObjectCount,&szFileNumber[iEnd],10);
          PrfWriteProfileData(hInstalledProfile,"Installed",szFileNumber,&hObject,sizeof(HOBJECT));
          }
        else
          bObjectBad = TRUE;
        }
      PrfWriteProfileData(hInstalledProfile,"Installed","Objects",&iObjectCount,sizeof(int));
      }
    }
  if (bObjectBad || (hObject == 0))
    {
    sprintf(szMessage,"At least one desktop object was not created due to an unknown system error.");
    sprintf(szCaption,"Object(s) Not Created!");
    WinMessageBox(HWND_DESKTOP,
                  HWND_DESKTOP,
                  szMessage,
                  szCaption,
                  0,
                 (MB_MOVEABLE | MB_OK));
    }
gtFreePathMem:
  PrfCloseProfile(hInstalledProfile);
  PrfCloseProfile(hSourceProfile);
  return(bSuccess);
  }
コード例 #25
0
int main(int argc,
         char *argv[])
{
    HMQ             hmq;
    FRAMECDATA      fcd;
    QMSG            qmsg;
    BOOL            Proceed = TRUE;

    if (!(G_hab = WinInitialize(0)))
        return 1;

    if (!(hmq = WinCreateMsgQueue(G_hab, 0)))
        return 1;

    // now attempt to find the XWorkplace NLS resource DLL,
    // which we need for all resources (new with XWP 0.9.0)
    Proceed = LoadNLS();

    // load browser path from USER_INI
    // V0.9.19 (2002-03-28) [umoeller]
    if (PrfQueryProfileString(HINI_USERPROFILE,
                              "WPURLDEFAULTSETTINGS", "DefaultBrowserExe",
                              (PSZ)DEFAULT_BROWSER,
                              G_szNetscapeApp,
                              sizeof(G_szNetscapeApp)))
    {
        // make sure this is not NETSCDDE.EXE, or we'll have
        // plenty of problems restarting ourselves infinitely
        // V0.9.19 (2002-04-02) [umoeller]
        if (strhistr(G_szNetscapeApp, "netscdde.exe"))
            strlcpy(G_szNetscapeApp, DEFAULT_BROWSER, sizeof(G_szNetscapeApp));
    }

    // load browser startup dir from USER_INI
    // V0.9.19 (2002-03-28) [umoeller]
    PrfQueryProfileString(HINI_USERPROFILE,
                          "WPURLDEFAULTSETTINGS", "DefaultWorkingDir",
                          "",
                          G_szStartupDir,
                          sizeof(G_szStartupDir));

    if (Proceed)
    {
        // parse parameters on cmd line
        if (argc > 1)
        {
            SHORT           i = 0;

            while (i++ < argc - 1)
            {
                if (argv[i][0] == '-')
                {
                    SHORT           i2;

                    for (i2 = 1; i2 < strlen(argv[i]); i2++)
                    {
                        switch (argv[i][i2])
                        {
                            case 'n':
                                G_optNewWindow = TRUE;
                                break;

                            case 'x':
                                G_optExecute = FALSE;
                                break;

                            case 'm':
                                G_optMinimized = TRUE;
                                break;

                            case 'h':
                                G_optHidden = TRUE;
                                break;

                            case 'X':
                                G_optConfirmStart = FALSE;
                                break;

                            case 'p':   // netscape path

                                if (i < argc)
                                {
                                    strlcpy(G_szNetscapeApp, argv[i + 1], sizeof(G_szNetscapeApp));
                                    i++;
                                    i2 = 1000;
                                }
                                else
                                {
                                    ExplainParams();
                                    Proceed = FALSE;
                                }
                                break;

                            case 's':   // startup dir V0.9.16 (2001-10-02) [umoeller]
                            {
                                if (i < argc)
                                {
                                    strlcpy(G_szStartupDir, argv[i + 1], sizeof(G_szStartupDir));
                                    i++;
                                    i2 = 1000;
                                }
                                else
                                {
                                    ExplainParams();
                                    Proceed = FALSE;
                                }
                                break;
                            }

                            case 'S':   // DDE server name V0.9.16 (2001-10-02) [umoeller]
                                if (i < argc)
                                {
                                    strlcpy(G_szDDENetscape, argv[i + 1], sizeof(G_szDDENetscape));
                                    i++;
                                    i2 = 1000;
                                }
                                else
                                {
                                    ExplainParams();
                                    Proceed = FALSE;
                                }
                                break;

                            case 'P':   // netscape parameters

                                if (i < argc)
                                {
                                    strlcpy(G_szNetscapeParams, argv[i + 1], sizeof(G_szNetscapeParams));
                                    i++;
                                    i2 = 1000;
                                }
                                else
                                {
                                    ExplainParams();
                                    Proceed = FALSE;
                                }
                                break;

                            case 'D':   // debug, show list box window w/ DDE msgs

                                G_optDebug = TRUE;
                                break;

                            case 'q': // added V0.9.1 (2000-02-07) [umoeller]
                                G_optQuiet = TRUE;
                                break;

                            default:    // unknown parameter
                                ExplainParams();
                                Proceed = FALSE;
                                break;
                        }
                    }
                }
                else
                {
                    // no option ("-"): seems to be URL
                    _PmpfF(("got URL [%s]", argv[i]));
                    // if the URL contains spaces, we enclose it in quotes
                    // V1.0.0 (2002-09-09) [umoeller]: not only spaces,
                    // but other weird characters too
                    if (strpbrk(argv[i], " &|="))
                        sprintf(G_szURL, "\"%s\"", argv[i]);
                    else
                        strlcpy(G_szURL, argv[i], sizeof(G_szURL));
                }
            }
        }

        if (strlen(G_szURL) == 0)
        {
            // no URL given: explain
            ExplainParams();
            Proceed = FALSE;
        }

        if (Proceed)
        {
            // OK, parameters seemed to be correct:
            // create the main window, which is only
            // visible in Debug mode ("-D" param). But
            // even if not in debug mode, this window is
            // used for DDE message processing.
            fcd.cb = sizeof(FRAMECDATA);
            fcd.flCreateFlags = FCF_TITLEBAR |
                                   FCF_SYSMENU |
                                   FCF_MENU |
                                   FCF_SIZEBORDER |
                                   FCF_SHELLPOSITION |
                                   FCF_MINMAX |
                                   FCF_TASKLIST;

            fcd.hmodResources = NULLHANDLE;
            // set our resource key (so PM can find menus, icons, etc).
            fcd.idResources = DDEC;
            // create the frame
            G_hwndDebug = WinCreateWindow(HWND_DESKTOP,
                                          WC_FRAME,
                                          (PSZ)NETSCDDE_TITLE,
                                          0, 0, 0, 0, 0,
                                          NULLHANDLE,
                                          HWND_TOP,
                                          DDEC,
                                          &fcd,
                                          NULL);

            if (!G_hwndDebug)
                return 1;

            // set the NetscDDE icon for the frame window
            WinSendMsg(G_hwndDebug,
                       WM_SETICON,
                       (MPARAM)WinLoadPointer(HWND_DESKTOP, G_hmodNLS,
                                              ID_ND_ICON),
                       NULL);

            // create a list window child
            G_hwndListbox = WinCreateWindow(G_hwndDebug,
                                            WC_LISTBOX,
                                            NULL,
                                            LS_HORZSCROLL,
                                            0, 0, 0, 0,
                                            G_hwndDebug,
                                            HWND_BOTTOM,
                                            FID_CLIENT,
                                            NULL,
                                            NULL);

            // we must intercept the frame window's messages;
            // we save the return value (the current WndProc),
            // so we can pass it all the other messages the frame gets.
            G_SysWndProc = WinSubclassWindow(G_hwndDebug, (PFNWP) fnwpMain);

            // the window we just created is normally invisible; we
            // will only display it if the (undocumented) "-D" option
            // was given on the command line.
            if (G_optDebug)
            {
                WinShowWindow(G_hwndDebug, TRUE);
                ShowMessage("Entering msg loop");
            }

            // now show "Contacting Netscape"
            if (!G_optQuiet)
            {
                G_hwndContacting = WinLoadDlg(HWND_DESKTOP, G_hwndDebug,
                                            WinDefDlgProc,
                                            G_hmodNLS, ID_NDD_CONTACTING,
                                            0);
                WinShowWindow(G_hwndContacting, TRUE);
            }

            // now post msg to main window to initiate DDE
            if (!G_optDebug)
                WinPostMsg(G_hwndDebug, WM_COMMAND, MPFROM2SHORT(IDM_INITIATE, 0), 0);

            //  standard PM message loop
            while (WinGetMsg(G_hab, &qmsg, NULLHANDLE, 0, 0))
            {
                WinDispatchMsg(G_hab, &qmsg);
            }
        }                           // end if (proceed)

        // clean up on the way out
        WinDestroyWindow(G_hwndContacting);
        G_hwndContacting = NULLHANDLE;
    }

    WinDestroyMsgQueue(hmq);
    WinTerminate(G_hab);

    return 0;
}
コード例 #26
0
ファイル: PRNAPI.C プロジェクト: OS2World/DEV-SAMPLES-DBCS
BOOL PrnCreatePrinterList(PPRN pprn)

{
PCHAR	  pch;			   /* String Character Pointer		*/
PPRQINFO3 pQueueInfo;		   /* Queue Information			*/
ULONG	  aulVersion[2];	   /* Version Number Holder		*/
ULONG	  cReturned;		   /* Returned Queue Count		*/
ULONG	  cTotal;		   /* Total Count			*/
ULONG	  cbNeeded;		   /* Buffer Size			*/
register INT i;			   /* Loop Counter			*/
register UINT n;		   /* Loop Counter			*/

DosQuerySysInfo(QSV_VERSION_MAJOR, QSV_VERSION_REVISION, aulVersion,
		2UL * sizeof(ULONG));

		       /* Determine the	amount of memory required for	*/
		       /* queue	information				*/

SplEnumQueue((PSZ)NULL,	3UL, (PVOID)NULL, 0UL, &cReturned, &cTotal,
	     &cbNeeded,	NULL);

		       /* Check	to see if any printers were detected	*/
		       /* and if none were found, return with the no	*/
		       /* no queue list	retrieved flag			*/
if ( cTotal == 0L )
   {
   pprn->hAB	 = 0UL;
   pprn->cQueues = 0;
   return(FALSE);
   }
		       /* Allocate memory for the queue	list		*/

if ( DosAllocMem((PPVOID)(PVOID)&pQueueInfo, cbNeeded, PAG_READ	| PAG_WRITE | PAG_COMMIT) )
   {
   pprn->hAB	 = 0UL;
   pprn->cQueues = 0;
   return(FALSE);
   }
		       /* Retrieve the queue list from the system	*/

SplEnumQueue((PSZ)NULL,	3UL, (PVOID)pQueueInfo,	cbNeeded, &cReturned,
	     &cTotal, &cbNeeded, NULL);

pprn->pquei = (PQUEINFO)malloc(sizeof(QUEINFO) * cTotal);

		       /* Scan the queue list looking for the entry	*/
		       /* that contains	the default queue and when	*/
		       /* found, save the queue	index entry		*/

for ( i	= 0; i < cReturned; i++	)
   {
   if (	pQueueInfo[i].pszName )
       {
       pprn->pquei[i].pszName =	(PSZ)malloc((n = strlen(pQueueInfo[i].pszName) + 1));
       memcpy(pprn->pquei[i].pszName, pQueueInfo[i].pszName, n);
       }
   else
       pprn->pquei[i].pszName =	NULL;

   if (	pQueueInfo[i].pszDriverName )
       {
       pprn->pquei[i].pszDriverName = (PSZ)malloc((n = strlen(pQueueInfo[i].pszDriverName) + 1));
       memcpy(pprn->pquei[i].pszDriverName, pQueueInfo[i].pszDriverName, n);
       }
   else
       pprn->pquei[i].pszDriverName = NULL;

   if (	pQueueInfo[i].pszPrinters )
       {
       pprn->pquei[i].pszPrinters = (PSZ)malloc((n = strlen(pQueueInfo[i].pszPrinters) + 1));
       memcpy(pprn->pquei[i].pszPrinters, pQueueInfo[i].pszPrinters, n);
       }
   else
       pprn->pquei[i].pszPrinters = NULL;

   pprn->pquei[i].pDriverData =	(PSZ)malloc((ULONG)pQueueInfo[i].pDriverData->cb);
   memcpy(pprn->pquei[i].pDriverData, pQueueInfo[i].pDriverData, (ULONG)pQueueInfo[i].pDriverData->cb);

		       /* Check	for the	default	queue			*/

   if (	((aulVersion[0]	== 20UL) && (aulVersion[1] >= 10UL)) ||	(aulVersion[0] > 20UL) )
       if ( pQueueInfo[i].fsType & PRQ3_TYPE_APPDEFAULT	)
	   pprn->iQueue	= i;
   }

if ( (aulVersion[0] == 20UL) &&	(aulVersion[1] < 10UL) )
   {
		       /* Get the default queue	to use			*/

   if (	PrfQueryProfileString(HINI_PROFILE, "PM_SPOOLER", "QUEUE", NULL,
			      pprn->szQueue, 256UL) )
       {
		       /* Truncate the semicolon delimiter in the queue	*/
		       /* name						*/

       pch = strchr(pprn->szQueue, ';');
       *pch = (CHAR)0;
       }
   else
		       /* No default queue name	found, use the first	*/
		       /* printer from the list				*/

       strcpy(pprn->szQueue, pQueueInfo->pszName);

		       /* Scan the queue list looking for the entry	*/
		       /* that contains	the default queue and when	*/
		       /* found, save the queue	index entry		*/

   for ( i = 0;	i < cReturned; i++ )
       if ( !strcmp(pprn->szQueue, pQueueInfo[i].pszName) )
	   {
	   pprn->iQueue	= i;
	   break;
	   }
   }
		       /* Save the queue information within the	printer	*/
		       /* information structure	and save the number of	*/
		       /* queues found within the system as well and	*/
		       /* return the queues found flag			*/

pprn->cQueues =	(INT)cReturned;

DosFreeMem((PVOID)pQueueInfo);

return(TRUE);
}
MRESULT EXPENTRY ObjectWinProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
{
  BOOL              bAutoStart;
  BOOL              bOK;
  CHAR              szTitle[ LEN_WORKSTRING ];
  CHAR              szWork[ LEN_WORKSTRING ];
  FILE              *f;
  HAB               hab;
  HWND              hwndToAck;
  PCHAR             pch;
  PGLOBALS          pg;
  LONG              i;
  LONG              cLines;
  STARTDATA         sd;
  ULONG             rc;
  ULONG             ulProcID;
  ULONG             ulSessionID;



  // store the handle of the window to ack upon task completion;
  hwndToAck = (HWND)mp1;
  hab = WinQueryAnchorBlock( hwnd );


  switch( msg ) {


  case WM_CREATE:
    // mp1 is pointer to globals; save it in object window words
    pg = (PGLOBALS)mp1;
    WinSetWindowULong( hwnd, QWL_USER, (ULONG) mp1 );


    // start the spooler ?
    PrfQueryProfileString( HINI_PROFILE, "PM_SPOOLER", "SPOOL", "1;", szWork, LEN_WORKSTRING );
    if( *szWork == '1' ) {

      // assume a bad spooler start
      pg->fSpooler = FALSE;

      memset( &sd, 0, sizeof( STARTDATA ) );
      sd.Length          = sizeof( STARTDATA );
      sd.FgBg            = 1;                            // 1=background
      sd.PgmTitle        = "Print Manager";
      sd.PgmName         = "PMSPOOL.EXE";
      sd.PgmInputs       = szWork;
      sd.SessionType     = 3;                            // 3=pm
      rc = DosStartSession( &sd, &ulSessionID, &ulProcID );
      switch( rc ) {
      case NO_ERROR:
        // pmspool.exe from 1.3 started ok
        pg->fSpooler = TRUE;
        break;
      default:
        Spl32QmInitialize( &rc );
        pmassert( pg->hab, 0 == rc );
        pg->fSpooler = ( 0 == rc );
        break;
      }

      if( ! pg->fSpooler )  {
        WinEnableMenuItem( pg->hwndMenubar,  IDM_SPOOLER,  FALSE );
        WinPostMsg( pg->hwndClient, WM_NACK_NO_SPOOLER, 0, 0 );
      }
    }


    // gather program data by parsing the INI file
    if( WinSendMsg( hwnd, WM_USER_ADD_PROGRAMS, (MPARAM)hwnd, 0 )) {
      // start the autostarts
      for( i = 0; i < pg->cStartem; i++ ) {
        if( pg->aStartem[ i ].bAutoStart ) {
          WinSendMsg( hwnd, WM_USER_START, (MPARAM)hwnd, (MPARAM) i );
        }
      }
    } else {
      // no ini file
      WinPostMsg( pg->hwndClient, WM_NACK_NO_INI, 0, 0 );
    }

    return (MRESULT) 0;





  case WM_USER_ACK:
    // nop for object window
    return (MRESULT) 0;



  case WM_USER_ADD_PROGRAMS:
    pg = (PGLOBALS) WinQueryWindowULong( hwnd, QWL_USER );

    // free allocations from the last time
    for( i = 0; i < pg->cStartem; i++ ) {
      if( pg->aStartem[ i ].pszTitle ) {
        free( pg->aStartem[ i ].pszTitle );
        pg->aStartem[ i ].pszTitle = NULL;
      }
      if( pg->aStartem[ i ].pszCMD ) {
        free( pg->aStartem[ i ].pszCMD );
        pg->aStartem[ i ].pszCMD = NULL;
      }
    }

    // reset how many items are startable
    pg->cStartem = 0;


    // open the text ini
    f = fopen( "\\MSHELL.INI" , "r" );
    if( !f ) {
      // no file
      WinPostMsg( hwndToAck, WM_NACK_NO_INI, (MPARAM)msg, (MPARAM) FALSE );
      return (MPARAM) FALSE;
    }

    // disable listbox painting
    WinEnableWindowUpdate( pg->hwndListbox, FALSE );

    // delete all in listbox
    WinSendMsg( pg->hwndListbox, LM_DELETEALL, 0, 0 );


    cLines = 0;
    i = 0;
    while( i < LEN_STARTLIST && fgets( szWork, LEN_WORKSTRING, f )) {
      cLines++;
      ltrim( trim( szWork ));
      memset( &(pg->aStartem[ i ]),  0, sizeof( STARTEM ));

      // comment lines begin with *
      if( NULL == strchr( "*", *szWork )  && strlen( szWork ) ) {

        // not a comment and not an empty line. parse it
        bOK = FALSE;

        // check for autostart symbol
        bAutoStart = ('!' == *szWork);

        if( bAutoStart ) {
          pch = strchr( szWork, '!' );
          pmassert( pg->hab, pch );
          *pch = ' ';
          ltrim( szWork );
        }

        // parse title up to ;
        pch = strtok( szWork, ";" );
        if( pch ) {
          strcpy( szTitle, pch );

          // parse the rest as a CMD start command
          pch = strtok( NULL, "\n" );
          bOK = (BOOL) pch;
        }

        // test result of parsing
        if( bOK ) {
          pg->aStartem[ i ].bAutoStart = bAutoStart;
          pg->aStartem[ i ].pszTitle   = strdup( szTitle );
          pg->aStartem[ i ].pszCMD     = strdup( pch );
          WinSendMsg( pg->hwndListbox, LM_INSERTITEM, (MPARAM) LIT_END, (MPARAM) pg->aStartem[i].pszTitle );
          // bump count of startable items
          i++;
        } else {
          // fire off a nack to elicit a message box; provide line number
          WinPostMsg( hwndToAck, WM_NACK_SYNTAX_ERROR, (MPARAM)msg, (MPARAM)cLines );
        }
      }
    }
    pg->cStartem = i;
    fclose( f );

    if( pg->cStartem > 0 ) {
      // select the first item
      WinSendMsg( pg->hwndListbox, LM_SELECTITEM, (MPARAM) 0, (MPARAM) TRUE );
    }

    // let listbox paint itself
    WinEnableWindowUpdate( pg->hwndListbox, TRUE );

    // success
    WinPostMsg( hwndToAck, WM_USER_ACK, (MPARAM)msg, (MPARAM) TRUE );
    return (MRESULT) TRUE;




  case WM_USER_START:
    // index of program to start is in mp2

    // start an invisible, transient CMD session to handle the stored start command
    pg = (PGLOBALS) WinQueryWindowULong( hwnd, QWL_USER );

    // make, modify a copy of the CMD start command
    sprintf( szWork, "/c %s",  pg->aStartem[ (SHORT)mp2 ].pszCMD );

    // a startdata structure for DosStartSession that will start CMD.EXE;
    // the parameter to CMD is the start command in szWork
    memset( &sd, 0, sizeof( STARTDATA ));
    sd.Length          = sizeof( STARTDATA );
    sd.PgmInputs       = szWork;
    sd.PgmControl      = SSF_CONTROL_INVISIBLE;

    rc = DosStartSession( &sd, &ulSessionID, &ulProcID );
    pmassert( hab, rc == 0 ||  rc == ERROR_SMG_START_IN_BACKGROUND   );

    WinPostMsg( hwndToAck, WM_USER_ACK, (MPARAM)msg, 0 );
    break;




  case WM_USER_START_CMD:
    // start CMD in a window; this is default for DosStartSession
    memset( &sd, 0, sizeof( STARTDATA ));
    sd.Length = sizeof( STARTDATA );
    rc = DosStartSession( &sd, &ulSessionID, &ulProcID );
    pmassert( hab, rc == 0 );
    WinPostMsg( hwndToAck, WM_USER_ACK, 0, 0 );
    break;

  }

  // default:
  return WinDefWindowProc( hwnd, msg, mp1, mp2 );
}
コード例 #28
0
void LoadToolSettings(void)
{
    char path[400+1];
    sprintf(path,"%s\\PROFOWL.INI",MyHomePath);
    //
    int ns = sizeof(UserTools[1].Name);
    int ps = sizeof(UserTools[1].Path);
    int ds = sizeof(UserTools[1].Dir);
    //
    HAB hab;
    HINI hini = PrfOpenProfile(hab,path);
    PrfQueryProfileString(hini,"profsowl","Tool1Name","",UserTools[1].Name,ns);
    PrfQueryProfileString(hini,"profsowl","Tool2Name","",UserTools[2].Name,ns);
    PrfQueryProfileString(hini,"profsowl","Tool3Name","",UserTools[3].Name,ns);
    PrfQueryProfileString(hini,"profsowl","Tool4Name","",UserTools[4].Name,ns);
    PrfQueryProfileString(hini,"profsowl","Tool5Name","",UserTools[5].Name,ns);
    PrfQueryProfileString(hini,"profsowl","Tool6Name","",UserTools[6].Name,ns);
    PrfQueryProfileString(hini,"profsowl","Tool7Name","",UserTools[7].Name,ns);
    PrfQueryProfileString(hini,"profsowl","Tool8Name","",UserTools[8].Name,ns);
    //--
    PrfQueryProfileString(hini,"profsowl","Tool1Path","",UserTools[1].Path,ps);
    PrfQueryProfileString(hini,"profsowl","Tool2Path","",UserTools[2].Path,ps);
    PrfQueryProfileString(hini,"profsowl","Tool3Path","",UserTools[3].Path,ps);
    PrfQueryProfileString(hini,"profsowl","Tool4Path","",UserTools[4].Path,ps);
    PrfQueryProfileString(hini,"profsowl","Tool5Path","",UserTools[5].Path,ps);
    PrfQueryProfileString(hini,"profsowl","Tool6Path","",UserTools[6].Path,ps);
    PrfQueryProfileString(hini,"profsowl","Tool7Path","",UserTools[7].Path,ps);
    PrfQueryProfileString(hini,"profsowl","Tool8Path","",UserTools[8].Path,ps);
    //--
    PrfQueryProfileString(hini,"profsowl","Tool1Dir","",UserTools[1].Dir,ds);
    PrfQueryProfileString(hini,"profsowl","Tool2Dir","",UserTools[2].Dir,ds);
    PrfQueryProfileString(hini,"profsowl","Tool3Dir","",UserTools[3].Dir,ds);
    PrfQueryProfileString(hini,"profsowl","Tool4Dir","",UserTools[4].Dir,ds);
    PrfQueryProfileString(hini,"profsowl","Tool5Dir","",UserTools[5].Dir,ds);
    PrfQueryProfileString(hini,"profsowl","Tool6Dir","",UserTools[6].Dir,ds);
    PrfQueryProfileString(hini,"profsowl","Tool7Dir","",UserTools[7].Dir,ds);
    PrfQueryProfileString(hini,"profsowl","Tool8Dir","",UserTools[8].Dir,ds);
    PrfCloseProfile(hini);
}
コード例 #29
0
void  h2font_restore( HWND hwndWnd, HINI hiniPrf, PSZ pszApp )
{
   PrfQueryProfileString( hiniPrf, pszApp, szPrfKeyFont, szDefaultFont, achFont, sizeof( achFont ) );
   WinSetPresParam( hwndWnd, PP_FONTNAMESIZE, strlen( achFont ) + 1, achFont );
   GetFontMetrics( hwndWnd, TRUE );
}
コード例 #30
0
MRESULT EXPENTRY MaskDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) {
   static PMASKSEL pmask;
   static BOOL flag = FALSE;   // TRUE se Š stato aggiunto o tolto un elemento
   static int idx;             // posizione item selezionato o di inserzione

   switch (msg) {
      case WM_INITDLG: {
         CHAR buf[FACESIZE];
         PSZ pszCur;
         int len;
         pmask = (PMASKSEL)PVOIDFROMMP(mp2);      // recupera indirizzo dati
         // imposta il font della barra del titolo:
         PrfQueryProfileString(HINI_USERPROFILE, "PM_SystemFonts",
                               "WindowTitles", "9.WarpSans", buf, FACESIZE);
         WinSetPresParam(WinWindowFromID(hwnd, FID_TITLEBAR), PP_FONTNAMESIZE,
                         sstrlen(buf) + 1, (PVOID)(buf));
         WinSetWindowPos(hwnd, HWND_BOTTOM, pmask->pos.x, pmask->pos.y, 0, 0,
                         SWP_MOVE | SWP_SHOW);    // visualizza la finestra
         pszCur = pmask->pszExt;
         DlgEFSetTxtLimit(hwnd, COMBO_MASK, 63);
         // riempie la listbox
         while (len = sstrlen(pszCur)) {
            DlgLboxInsertItem(hwnd, COMBO_MASK, LIT_SORTASCENDING, pszCur);
            pszCur += len + 1;
         } /* endwhile */
         } // end case WM_INITDLG:
         break;
      case WM_CONTROL:
         switch (SHORT2FROMMP(mp1)) {
            case CBN_EFCHANGE: {          // cambiamento testo
               BOOL enable;
               // pulsante OK abilitato se c'e' testo nell' entrifield
               enable = WinQueryDlgItemTextLength(hwnd, COMBO_MASK);
               WinEnableControl(hwnd, MASK_OK, enable);
               // pulsante ADD abilitato se c'Š testo non gi… presente
               WinQueryDlgItemText(hwnd, COMBO_MASK, 64, pmask->achSel);
               idx = isInListBox(hwnd, pmask->achSel, COMBO_MASK); 
               WinEnableControl(hwnd, MASK_STORE, enable && (idx < 0));
               // pulsante REMOVE abilitato se testo EF == item lista
               WinEnableControl(hwnd, MASK_DEL, idx >= 0);
               } // end case CBN_EFCHANGE:
               break;
            case CBN_LBSELECT:            // selezione item
               idx = isInListBox(hwnd, pmask->achSel, COMBO_MASK);
               WinEnableControl(hwnd, MASK_DEL, idx >= 0);
               break;
            default:
              break;
         } /* endswitch */
         break;
      case WM_COMMAND:
         switch (LOUSHORT(mp1)) {
            case MASK_OK:
               WinQueryDlgItemText(hwnd, COMBO_MASK, 64, pmask->achSel);
               if (flag)    // eventualmente aggiorna lista filespec
                  ProcMaskDlgExit(hwnd, pmask);
               SaveMaskDlgPos(hwnd, pmask);
               WinDismissDlg(hwnd, TRUE);
               break;
            case MASK_STORE:
               flag = TRUE;
               DlgLboxInsertItem(hwnd, COMBO_MASK, LIT_SORTASCENDING,
                                 pmask->achSel);
               DlgLboxSelectItem(hwnd, COMBO_MASK, -idx - 1);
               WinEnableControl(hwnd, MASK_STORE, FALSE);
               break;
            case MASK_DEL:
               flag = TRUE;
               idx = DlgLboxQuerySelectedItem(hwnd, COMBO_MASK);
               DlgLboxDeleteItem(hwnd, COMBO_MASK, idx);
               WinSetDlgItemText(hwnd, COMBO_MASK, "");
               break;
            default: 
               if (flag)    // eventualmente aggiorna lista filespec
                  ProcMaskDlgExit(hwnd, pmask);
               SaveMaskDlgPos(hwnd, pmask);
               WinDismissDlg(hwnd, FALSE);
               break;
         } /* endswitch */
         break;
      case WM_CLOSE:
         if (flag)    // eventualmente aggiorna lista filespec
            ProcMaskDlgExit(hwnd, pmask);
         SaveMaskDlgPos(hwnd, pmask);
         WinDismissDlg(hwnd, FALSE);
         break;
      default: 
         return WinDefDlgProc(hwnd, msg, mp1, mp2);
   } // end switch
   return (MRESULT) FALSE;
}