Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions
xpapi.cpp File Reference
#include <windows.h>
#include <stdio.h>
#include <stdarg.h>
#include "xpapi.h"
#include "mapiutl.h"

Go to the source code of this file.

Defines

#define COPYBUFSIZE   1024

Functions

WORD LOAD_DS XP_CallProcess (LPCSTR pPath, LPCSTR pCmdLine)
HKEY LOAD_DS RegOpenParent (LPCSTR pSection, HKEY hRootKey, REGSAM access)
HKEY LOAD_DS RegCreateParent (LPCSTR pSection, HKEY hMasterKey)
BOOL LOAD_DS GetConfigInfoStr (LPCSTR pSection, LPCSTR pKey, LPSTR pBuf, int lenBuf, HKEY hMasterKey)
BOOL LOAD_DS GetConfigInfoNum (LPCSTR pSection, LPCSTR pKey, DWORD *pVal, HKEY hMasterKey)
BOOL LOAD_DS SetConfigInfoStr (LPCSTR pSection, LPCSTR pKey, LPSTR pStr, HKEY hMasterKey)
BOOL LOAD_DS XP_GetInstallDirectory (LPCSTR pcurVersionSection, LPCSTR pInstallDirKey, LPSTR path, UINT nSize, HKEY hKey)
BOOL LOAD_DS XP_GetVersionInfoString (LPCSTR pNavigatorSection, LPCSTR pCurrentVersionKey, LPSTR pcurVersionStr, UINT nSize, HKEY hKey)
DWORD LOAD_DS XP_GetInstallLocation (LPSTR pPath, UINT nSize)
int LOAD_DS Is_16_OR_32_BIT_CommunitorRunning ()
BOOL LOAD_DS XP_CopyFile (LPCSTR lpExistingFile, LPCSTR lpNewFile, BOOL bFailifExist)

Define Documentation

#define COPYBUFSIZE   1024

Definition at line 293 of file xpapi.cpp.


Function Documentation

BOOL LOAD_DS GetConfigInfoNum ( LPCSTR  pSection,
LPCSTR  pKey,
DWORD pVal,
HKEY  hMasterKey 
)

Definition at line 124 of file xpapi.cpp.

{
       HKEY hKey;
       hKey = RegOpenParent(pSection, hMasterKey, KEY_QUERY_VALUE);
       if (!hKey)
       {
              return(FALSE);
       }

       DWORD len = sizeof(DWORD);
#ifndef WIN16
       BOOL retVal = (RegQueryValueEx(hKey, pKey, NULL, NULL, (LPBYTE)pVal, &len) == ERROR_SUCCESS);
#else
       BOOL retVal = (RegQueryValue(hKey, pKey, (char far*)pVal, (long far*)&len) == ERROR_SUCCESS);
#endif
       RegCloseKey(hKey);
       return(retVal);
}

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL LOAD_DS GetConfigInfoStr ( LPCSTR  pSection,
LPCSTR  pKey,
LPSTR  pBuf,
int  lenBuf,
HKEY  hMasterKey 
)

Definition at line 105 of file xpapi.cpp.

{
       HKEY hKey;
       hKey = RegOpenParent(pSection, hMasterKey, KEY_QUERY_VALUE);
       if (!hKey)
       {
              return(FALSE);
       }

       DWORD len = (DWORD)lenBuf;
#ifndef WIN16
       BOOL retVal = (RegQueryValueEx(hKey, pKey, NULL, NULL, (LPBYTE)pBuf, &len) == ERROR_SUCCESS);
#else
       BOOL retVal = (RegQueryValue(hKey, pKey, pBuf, (long far*)&len) == ERROR_SUCCESS);
#endif
       RegCloseKey(hKey);
       return(retVal);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 282 of file xpapi.cpp.

{
  if (FindWindow("AfxFrameOrView", NULL) && !FindWindow("aHiddenFrameClass", NULL))
              return(16);
       else if (FindWindow("aHiddenFrameClass", NULL))
              return(32);
       else 
              return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

HKEY LOAD_DS RegCreateParent ( LPCSTR  pSection,
HKEY  hMasterKey 
)

Definition at line 95 of file xpapi.cpp.

{
       HKEY hKey;
       if (RegCreateKey(hMasterKey, pSection, &hKey) != ERROR_SUCCESS)
       {
              return(NULL);
       }        
       return(hKey);
}

Here is the caller graph for this function:

HKEY LOAD_DS RegOpenParent ( LPCSTR  pSection,
HKEY  hRootKey,
REGSAM  access 
)

Definition at line 78 of file xpapi.cpp.

{
       HKEY hKey;
#ifndef WIN16
       if (RegOpenKeyEx(hRootKey, pSection, 0, access, &hKey) != ERROR_SUCCESS)
       {
              return(NULL);
       }        
#else
    if (RegOpenKey(hRootKey, pSection, &hKey) != ERROR_SUCCESS)
    {
       return(NULL);
    }
#endif
       return(hKey);
}

Here is the caller graph for this function:

BOOL LOAD_DS SetConfigInfoStr ( LPCSTR  pSection,
LPCSTR  pKey,
LPSTR  pStr,
HKEY  hMasterKey 
)

Definition at line 143 of file xpapi.cpp.

{
       HKEY hKey;
       hKey = RegCreateParent(pSection, hMasterKey);
       if (!hKey)
       {
              return(FALSE);
       }
#ifndef WIN16
       BOOL retVal = (RegSetValueEx(hKey, pKey, 0, REG_SZ, (LPBYTE)pStr, lstrlen(pStr) + 1) == ERROR_SUCCESS);
#else
       BOOL retVal = (RegSetValue(hKey, pKey, REG_SZ, pStr, lstrlen(pStr) + 1) == ERROR_SUCCESS);
#endif
       RegCloseKey(hKey);
       return(retVal);
}

Here is the call graph for this function:

Here is the caller graph for this function:

WORD LOAD_DS XP_CallProcess ( LPCSTR  pPath,
LPCSTR  pCmdLine 
)

Definition at line 49 of file xpapi.cpp.

{            
       WORD wReturn = 0;
#ifndef WIN16
       STARTUPINFO startupInfo;
       PROCESS_INFORMATION processInfo;

       memset(&startupInfo, 0, sizeof(startupInfo));
       startupInfo.cb = sizeof(startupInfo);
       if (wReturn = CreateProcess(pPath, (LPTSTR)pCmdLine, NULL, NULL, FALSE, CREATE_DEFAULT_ERROR_MODE | CREATE_NEW_PROCESS_GROUP, NULL, NULL, &startupInfo, &processInfo))
       {
              WaitForInputIdle(processInfo.hProcess, 120000);
       }
#else       
       // char szMsg[80];   
       char szExecute[512];
       lstrcpy(szExecute, pPath);
       lstrcat(szExecute, " ");
       lstrcat(szExecute, pCmdLine);
       wReturn = WinExec(szExecute,SW_SHOW);
       
       if (wReturn < 32) 
       {
           wReturn = 0;
       }
#endif
       return wReturn;
}

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL LOAD_DS XP_CopyFile ( LPCSTR  lpExistingFile,
LPCSTR  lpNewFile,
BOOL  bFailifExist 
)

Definition at line 340 of file xpapi.cpp.

{                                                  
#ifdef WIN32
  return      CopyFile(lpExistingFile, lpNewFile, bFailifExist);
#else                                                             
  return    Win16CopyFile(lpExistingFile, lpNewFile, TRUE);
#endif
}    

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL LOAD_DS XP_GetInstallDirectory ( LPCSTR  pcurVersionSection,
LPCSTR  pInstallDirKey,
LPSTR  path,
UINT  nSize,
HKEY  hKey 
)

Definition at line 161 of file xpapi.cpp.

{   
#ifdef WIN32   
       if (!GetConfigInfoStr(pcurVersionSection, pInstallDirKey, path, nSize, hKey))
       {  
              return FALSE;
       }
       else
       {
              return TRUE;
       }       
#else
       if ( 0 < GetPrivateProfileString(pcurVersionSection, pInstallDirKey,"ERROR", path, nSize, szNetscapeINI))
       {
              return TRUE;
       }
       else
       {
              return FALSE;
       }
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:

DWORD LOAD_DS XP_GetInstallLocation ( LPSTR  pPath,
UINT  nSize 
)

Definition at line 209 of file xpapi.cpp.

{           
char curVersionStr[256]; 
char curVersionSection[256];

  if (!pPath) 
    return  MAPI_E_LOGON_FAILURE;
  
#ifdef WIN32
  if (!XP_GetVersionInfoString(szNavigatorSection, szCurrentVersionKey, curVersionStr, 
    sizeof(curVersionStr), HKEY_LOCAL_MACHINE))
  {
    return (MAPI_E_LOGON_FAILURE);
  }
  
  wsprintf(curVersionSection, szNavigatorCurVersionSection, curVersionStr);
              
  if (!XP_GetInstallDirectory(curVersionSection, szInstallDirKey, pPath, 
    nSize, HKEY_LOCAL_MACHINE))
  {
    return (MAPI_E_ACCESS_DENIED);
    
  }
  
  lstrcat(pPath, "\\");
  lstrcat(pPath, "Program\\netscape.exe");
  
  return SUCCESS_SUCCESS;
#else
  if (32 == Is_16_OR_32_BIT_CommunitorRunning())
  {   
    if (!GetConfigInfoStr("snews\\shell\\open", "command", curVersionStr, sizeof(curVersionStr), HKEY_CLASSES_ROOT))
    {
      return (MAPI_E_ACCESS_DENIED);
    }
    else
    {  
      char *pFind = strstr(curVersionStr,"-h");
      
      if (pFind)
      {
        *pFind=0;
        lstrcpy(pPath,curVersionStr);
      }
      else
      {
        return (MAPI_E_ACCESS_DENIED);
      }
    }
    
    return SUCCESS_SUCCESS;
  }
  else //setup up to start navstart since we are a sixteen bit DLL.
  {
    if (!XP_GetVersionInfoString(szNavigatorSection, szCurrentVersionKey, curVersionStr, sizeof(curVersionStr), HKEY_LOCAL_MACHINE))
    {
      return (MAPI_E_LOGON_FAILURE);
    }
    
    wsprintf(curVersionSection, szNavigatorCurVersionSection, curVersionStr);
    
    if (!XP_GetInstallDirectory(curVersionSection, szInstallDirKey, pPath,nSize, HKEY_LOCAL_MACHINE))
    {
      return (MAPI_E_ACCESS_DENIED);             
    }
    
    lstrcat(pPath, "\\");
    lstrcat(pPath, "NAVSTART.EXE");
    return SUCCESS_SUCCESS; 
  }
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL LOAD_DS XP_GetVersionInfoString ( LPCSTR  pNavigatorSection,
LPCSTR  pCurrentVersionKey,
LPSTR  pcurVersionStr,
UINT  nSize,
HKEY  hKey 
)

Definition at line 185 of file xpapi.cpp.

{ 
#ifdef WIN32
       if (!GetConfigInfoStr(pNavigatorSection, pCurrentVersionKey, pcurVersionStr, nSize, HKEY_LOCAL_MACHINE))
       {
              return FALSE;
       }               
       else
       {
              return TRUE;
       }
#else 
       if ( 0 < GetPrivateProfileString(pNavigatorSection, pCurrentVersionKey,"ERROR", pcurVersionStr, nSize, szNetscapeINI))
       {
              return TRUE;
       }
       else
       {
              return FALSE;
       }
#endif

}   

Here is the call graph for this function:

Here is the caller graph for this function: