VB6, The Registry and PDF Printing

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MLC
    New Member
    • Mar 2008
    • 2

    VB6, The Registry and PDF Printing

    I have read many threads and discussions on how to supress the PDF Writer prompt screen and allocate a filename directly to the PDF file from a VB6 program. I am therefore trying to set the Registry value 'PDFFileName' to the filename I want before attempting to print.

    The line of code I have is:

    retval = RegSetValueExSt ring(HKEY_CURRE NT_USER, "Software\ADOBE \Acrobat PDFWriter\PDFFi leName", 0, REG_SZ, MyFilename, mylen)

    MyFilename is a string which has a filename with full path, and mylen is the length of this string in bytes as returned by LenB. The return value I get is 0 - ie. there is no error, and yet it doesn't actually do anything!

    The information I have read about the function RegSetValueExSt ring says that it will create the value if it is not already there.

    I have tried creating the PDFFileName value directly via regedit before running the code but it doesn't set it.

    I have tried creating the PDFFileName value in regedit and allocating it a valid filename and path. Then the VB6 behaves as I want, as it bypasses the prompt window from PDF Writer and creates the file (and then removes the PDFFilename setting!)

    I feel like I am going round in circles - any thoughts anyone??????

    Thanks
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    I think you need to "open" and "close" the key. See this example code from MS' website...

    [CODE=vb]Private Sub SetKeyValue (sKeyName As String, sValueName As String, _
    vValueSetting As Variant, lValueType As Long)
    Dim lRetVal As Long 'result of the SetValueEx function
    Dim hKey As Long 'handle of open key

    'open the specified key
    lRetVal = RegOpenKeyEx(HK EY_CURRENT_USER , sKeyName, 0, _
    KEY_SET_VALUE, hKey)
    lRetVal = SetValueEx(hKey , sValueName, lValueType, vValueSetting)
    RegCloseKey (hKey)
    End Sub
    [/CODE]

    Comment

    • MLC
      New Member
      • Mar 2008
      • 2

      #3
      Thanks for the reply.

      I have just tried what you suggested - both the 'open' and the 'set' return a zero (no error) return value but it is still not doing anything to the registry!

      Comment

      Working...