HOWTO: Determine the Windows Messaging Subsystem Default

ID: Q195850


The information in this article applies to:
  • Microsoft Visual FoxPro for Windows, versions 3.0, 3.0b, 5.0, 5.0a, 6.0


SUMMARY

Occasionally, when you are working on MAPI-enabled FoxPro applications you might need to determine what the default Windows Messaging profile is on a target computer. This article demonstrates how to accomplish this using the Windows API.


MORE INFORMATION

Step-by-Step Procedures

  1. In Visual FoxPro, open a new program window by typing the following in the Command window:


  2. 
          MODIFY COMMAND 
  3. Copy the following code into a program file:


  4. 
       #DEFINE HKey_CURRENT_USER 2147483649
       DECLARE INTEGER RegCloseKey IN Win32API ;
          INTEGER nHKey
       DECLARE INTEGER RegOpenKey IN Win32API ;
          INTEGER nHKey, STRING @cSubKey, INTEGER @nResult
       DECLARE RegEnumValue IN ADVAPI32 INTEGER nKeyHandle, INTEGER iValue, ;
          STRING @cValueName, INTEGER @iValueLen, INTEGER, STRING @cTypeCode, ;
          STRING @cDataValue, INTEGER @iDataLen
    
       nSubKey = 0
       nErrCode = 0
       nKeyHandle = 0
       iValue = 0
       cValueName = SPACE(255)
       iValueLen = 255
       cTypeCode = SPACE(255)
       cDataValue = SPACE(255)
       iDataLen = 255
    
       *!* Determine what operating system you are on: Windows NT or
       *!* Windows 9x.
       IF "NT" $ OS(1)
          ckey = "Software\Microsoft\Windows NT\CurrentVersion\" + ;
             "Windows Messaging Subsystem\Profiles"
       ELSE
          ckey = "Software\Microsoft\Windows Messaging Subsystem\Profiles"
       ENDIF
    
       nErrCode = RegOpenKey(HKey_CURRENT_USER,ckey,@nKeyHandle)
       *!* If nErrCode <> 0, Windows messaging is probably not installed.
       IF nErrCode # 0
          WAIT WINDOW "Windows Messaging Key Not Present"
          RETURN nErrCode
       ENDIF
    
       RegEnumValue(nKeyHandle,0,@cValueName,@iValueLen,0,;
          @cTypeCode, @cDataValue, @iDataLen)
       *!* If cDataValue is blank, no profiles have been set up.
       IF EMPTY(cDataValue)
          WAIT WINDOW "No Windows Messaging Profiles Set"
          RETURN
       ELSE
          ? LEFT(cDataValue, iDataLen-1)
       ENDIF
       RegCloseKey(nKeyHandle) 
  5. Save and run this program.


  6. RESULT: You should see text echoed in the main FoxPro window. This is the default Windows Message profile for this computer.

Additional query words:

Keywords : kbMAPI kbVFp300 kbVFp300b kbVFp500 kbVFp500a kbVFp600
Version : WINDOWS:3.0,3.0b,5.0,5.0a,6.0
Platform : WINDOWS
Issue type : kbhowto


Last Reviewed: August 26, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.