Stellen Sie die Landschaft Druckoption durch DEVMODE

  • Ich weiß nicht, wo ich falsch lag, aber es ändert nichts an der die Landschaft.
    Wo habe ich falsch gemacht?


    Spoiler anzeigen
    [autoit]


    #include<WinPrint.au3>
    #Include <WinAPI.au3>
    #Include <String.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Global Const $DC_DRIVER = 11
    Global Const $DM_IN_PROMPT=4

    [/autoit] [autoit][/autoit] [autoit]

    Global Const $OFFS_ORIENT_FLAG=41 ; offset to Orientation flag
    Global Const $OFFS_ORIENT_VALUE=45 ; offset to Orientation value

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Global $hWindow, $cPrinter, $cDriver, $cPort, $hPrinter, $nBufsize, $cDevmode

    [/autoit] [autoit][/autoit] [autoit]

    $res =_Identify_Printers()
    $res = StringSplit(StringReplace ( StringReplace ( StringReplace ( $res, "*", ":"), ">", ""), "<", ""), ":")
    $res_=DllCall("winspool.drv", "long", "DeviceCapabilitiesA", "str", $cPrinter, "str", $cPort, "int", $DC_DRIVER, "str", Chr(0), "long", 0)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    $cPrinter = $res[1]
    $cDriver = $res_[0]
    $cPort = $res[2]
    $hWindow = WinGetHandle ('AutoIt3.exe')

    [/autoit] [autoit][/autoit] [autoit]

    $hPrinter = 0

    [/autoit] [autoit][/autoit] [autoit]

    $hPrinter = _OpenPrinter($cPrinter, $hPrinter, 0)
    IF $hPrinter = 0 Then
    MsgBox(0, "Error", "Could not open default printer. ")
    ENDIF

    [/autoit] [autoit][/autoit] [autoit]

    ;being called this way the function returns DEVMODE buffer required size
    $nBufsize = _DocumentProperties($hWindow, $hPrinter, $cPrinter, 0, 0, 0)
    $cDevmode = _StringRepeat(Chr(0), $nBufsize) ;

    [/autoit] [autoit][/autoit] [autoit]

    _SetOrient($DMORIENT_LANDSCAPE)
    _DocumentProperties($hWindow, $hPrinter, $cPrinter, $cDevmode, $cDevmode, $DM_IN_PROMPT+$DM_IN_BUFFER+$DM_OUT_BUFFER)

    [/autoit] [autoit][/autoit] [autoit]

    _ClosePrinter($hPrinter)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _SetOrient($nOrient)
    ; DEVMODE is adjusted programmatically
    ; DM_IN_PROMPT not used -- the dialog window is not shown
    LOCAL $dmFlags
    ;reading printer configuration
    _DocumentProperties($hWindow, $hPrinter, $cPrinter, $cDevmode, 0, $DM_OUT_BUFFER)
    $dmFlags = _buf2word(StringMid($cDevmode, $OFFS_ORIENT_FLAG, 4))
    $dmFlags = BitOR($dmFlags, $DM_ORIENTATION)
    $cDevmode = StringReplace($cDevmode, $OFFS_ORIENT_FLAG, 4, _num2dword($dmFlags))
    $cDevmode = StringReplace($cDevmode, $OFFS_ORIENT_VALUE, 2, _num2word($nOrient))
    ; using modified DEVMODE structure in the next call
    _DocumentProperties($hWindow, $hPrinter, $cPrinter,$cDevmode, $cDevmode, $DM_IN_BUFFER+$DM_OUT_BUFFER)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _buf2word($lcBuffer)
    $return = Asc(StringMid($lcBuffer, 1, 1))+Asc(StringMid($lcBuffer, 2, 1))*256
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _num2word($lnValue)

    [/autoit] [autoit][/autoit] [autoit]

    RETURN Chr(MOD($lnValue,256)) + CHR(INT($lnValue/256))

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _num2dword($lnValue)

    [/autoit] [autoit][/autoit] [autoit]

    Global Const $m0=256
    Global Const $m1=65536
    Global Const $m2=16777216

    [/autoit] [autoit][/autoit] [autoit]

    Local $b0, $b1, $b2, $b3

    [/autoit] [autoit][/autoit] [autoit]

    $b3 = Int($lnValue/$m2)
    $b2 = Int(($lnValue - ($b3*$m2))/$m1)
    $b1 = Int(($lnValue - ($b3*$m2) - ($b2*$m1))/$m0)
    $b0 = Mod($lnValue, $m0)

    [/autoit] [autoit][/autoit] [autoit]

    RETURN Chr($b0)+Chr($b1)+Chr($b2)+Chr($b3)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ;:::::::::::::::::::::::::::::::::::::::::::::::::::::::: Functions

    [/autoit] [autoit][/autoit] [autoit]

    Func _GetProfileStringA($cApp, $cKeyName, $cDefault, $cReturn, $nSize)
    $result = DllCall("kernel32.dll","dword","GetProfileStringA", "str", $cApp, "str", $cKeyName, "str", $cDefault, "str", $cReturn, "dword", $nSize)
    Return $result
    EndFunc

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _DocumentProperties($hParent,$hPrinter,$szPrinter, $pDevModeOut ,$pDevModeIn=0,$fMode=0)
    Local $err,$hwnd
    ;get a handle for property page parent
    If $hParent = 0 Then
    $hwnd = _WinAPI_GetDesktopWindow()
    Else
    $hwnd = $hParent
    EndIf
    Local $result = DllCall("winspool.drv","int","DocumentPropertiesW","hwnd",$hwnd,"handle",$hPrinter,"wstr",$szPrinter,"ptr",DllStructGetPtr($pDevModeOut),"ptr",$pDevModeIn,"dword",$fMode)
    $err = @error
    If $err Then Return SetError($err,0,0)
    Return $result[0]
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _DeviceCapabilities($objPrinterName, $objPrinterPortName, $fwCapability, $pOutput, $pDevMode)

    [/autoit] [autoit][/autoit] [autoit]

    If $pOutput = "" Then $pOutput = Chr(0)
    If $pDevMode = 0 Then $pDevMode = 0

    [/autoit] [autoit][/autoit] [autoit]

    $result = DllCall("winspool.drv", "long", "DeviceCapabilitiesA", _
    "str", $objPrinterName, "str", $objPrinterPortName, _
    "int", $fwCapability, "str", $pOutput, "long", $pDevMode)

    [/autoit] [autoit][/autoit] [autoit]

    Return $result[0]

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _OpenPrinter($pPrinter,ByRef $phPrinter,$pDefaults=-1)
    Local $err,$tPDF
    If $pDefaults = -1 Then
    $tPDF = DllStructCreate("ptr;ptr;ptr")
    DllStructSetData($tPDF,3,8)
    $pDefaults = DllStructGetPtr($tPDF)
    EndIf
    Local $t_pPrinter = DllStructCreate("ptr")
    $phPrinter = DllStructGetPtr($t_pPrinter)

    [/autoit] [autoit][/autoit] [autoit]

    Local $result = DllCall("winspool.drv","int","OpenPrinterW","wstr",$pPrinter,"ptr",$phPrinter,"ptr",$pDefaults)
    $err = @error
    $tPDF = 0
    If $err Then Return SetError($err,0,0)
    Return $result[0]
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _ClosePrinter($pPrinter)
    Local $err
    Local $result = DllCall("winspool.drv","int","ClosePrinter","handle",$pPrinter)
    $err = @error
    If $err Then Return SetError($err,0,0)
    Return $result[0]
    EndFunc
    ;::::::::::::::::::::::::::::::::::::::::::::::::::::::::

    [/autoit] [autoit][/autoit] [autoit]

    Func _Identify_Printers()
    Local $key, $default, $i = 1, $list, $name
    If @OSType = "WIN32_WINDOWS" Then
    $key = "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Print\Printers"
    $default = RegRead("HKEY_CURRENT_CONFIG\System\CurrentControlSet\Control\Print\Printers","Default")
    Else;WIN_NT type
    $key = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Printers"
    $default = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows","Device")
    $default = StringLeft($default, StringInStr($default,",")-1);remove info after comma...
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    ;;;$list = StringReplace($list, $default, '** ' & $default)

    [/autoit] [autoit][/autoit] [autoit]

    ; ENUMERATE LOCAL PRINTERS (AND ALSO 9x PRINTERS SHARED ON OTHER COMPUTERS)
    While 1
    ;#cs - enum bug workaround
    RegRead($key, "")
    If @error = 1 Then ExitLoop
    ;#ce
    Local $name = RegEnumKey($key, $i)
    If @error Then ExitLoop
    Local $port = "<" & RegRead($key & "\" & $name, "Port") & ">"
    ;************************************************************************modified
    If $name = $default Then
    $port = '* ' & $port

    [/autoit] [autoit][/autoit] [autoit]

    $res = $name &$port

    [/autoit] [autoit][/autoit] [autoit]

    EndIf
    ;***********************************************************************
    Local $driver = RegRead($key & "\" & $name, "Printer Driver")
    Local $shared = RegRead($key & "\" & $name, "Share Name")
    If $shared <> "" Then $shared = "$ " & $shared
    $list = $list & $port & " " & $name & " [" & $driver & "] " & $shared & @CRLF
    $i = $i + 1

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    ; ENUMERATE 2000/XP PRINTERS SHARED ON OTHER COMPUTERS
    If @OSType = "WIN_NT" Then
    Local $i = 1, $j = 1
    While 1
    ;#cs - enum bug workaround
    RegRead($key, "")
    If @error = 1 Then ExitLoop
    ;#ce
    Local $serverAddress = RegEnumKey($key, $i)
    If @error Then ExitLoop
    $j = 1
    While 1
    ;#cs - enum bug workaround
    RegRead($key & "\" & $serverAddress & "\Printers", "")
    If @error = 1 Then ExitLoop(2)
    ;#ce
    Local $networkedPrinter = RegEnumKey($key & "\" & $serverAddress & "\Printers", $j)
    If @error Then ExitLoop(2)
    $name = RegRead($key & "\" & $serverAddress & "\Printers\" & $networkedPrinter, "Name")
    Local $share = "<\\" & $serverAddress & "\" & RegRead($key & "\" & $serverAddress & "\Printers\" & $networkedPrinter, "Share Name") & ">"
    If $name = $default Then $share = '* ' & $share
    $list = $list & $share & " " & $name & " [" & $driver & "]" & @CRLF
    $j = $j + 1
    WEnd
    $i = $i + 1
    WEnd
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    If $list = "" Then $list = "No printers detected" & @CRLF
    ;Return $list ; default value
    Return $res
    EndFunc

    [/autoit]

    4 Mal editiert, zuletzt von Real Shyfox (14. Mai 2011 um 17:26)

  • Hey,

    Why you write in English @ a German Forum?


    Weil ich weiß, sehr wenig Deutsch.
    Aber ich werde meine Frage auf Deutsch stellen. Was ich im Mai Skript wollen ist die Veränderung der Landschaft durch die DEVMODE-Struktur. Aber es scheint, dass etwas schief geht.

  • It's probably a better Idea to post your problem in the english AutoIt Forum (see Sprengers link), as not a lot of people speak english here. Also WinPrint.au3 doesn't seem to be a standard include, so a link to the File would be appreciated. ;)

  • It's probably a better Idea to post your problem in the english AutoIt Forum (see Sprengers link), as not a lot of people speak english here. Also WinPrint.au3 doesn't seem to be a standard include, so a link to the File would be appreciated. ;)


    Ich bin in der Lage zu sprechen und Deutsch lesen, so ist es nicht so ein großes Problem. Ich habe schon gefragt, in der Englisch-Forum, aber es scheint, dass sie nicht in der Lage, mir zu helfen, so bist, zuletzt Lösung habe ich hierher kam.
    Vielen Dank für Ihre Hilfe.

  • Jetzt fehlen allerdings noch sämtliche Variablen, welche die DLL Structs enthalten. Mit einem funktionsfähigen Script würdest du uns die Arbeit auf jeden Fall erheblich erleichtern. ;)


    Ich schaute auf meinen Code und war eine ältere Version. Es tut mir leid. Dies ist die letzte Version.

    Spoiler anzeigen
    [autoit]


    #Include <WinAPI.au3>
    #Include <String.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Global Const $DC_DRIVER = 11
    Global Const $DM_IN_PROMPT=4

    [/autoit] [autoit][/autoit] [autoit]

    Global Const $DMORIENT_PORTRAIT = 1
    Global Const $DMORIENT_LANDSCAPE = 2

    [/autoit] [autoit][/autoit] [autoit]

    Global Const $DM_IN_BUFFER = 8
    Global Const $DM_OUT_BUFFER = 2

    [/autoit] [autoit][/autoit] [autoit]

    Global Const $DM_ORIENTATION = 1

    [/autoit] [autoit][/autoit] [autoit]

    Global Const $OFFS_ORIENT_FLAG=41 ; offset to Orientation flag
    Global Const $OFFS_ORIENT_VALUE=45 ; offset to Orientation value

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Global $hWindow, $cPrinter, $cDriver, $cPort, $hPrinter, $nBufsize, $cDevmode

    [/autoit] [autoit][/autoit] [autoit]

    $res =_Identify_Printers()
    $res = StringSplit(StringReplace ( StringReplace ( StringReplace ( $res, "*", ":"), ">", ""), "<", ""), ":")
    $res_=DllCall("winspool.drv", "long", "DeviceCapabilitiesA", "str", $cPrinter, "str", $cPort, "int", $DC_DRIVER, "str", Chr(0), "long", 0)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    $cPrinter = $res[1]
    $cDriver = $res_[0]
    $cPort = $res[2]
    $hWindow = WinGetHandle ('AutoIt3.exe')

    [/autoit] [autoit][/autoit] [autoit]

    $hPrinter = 0

    [/autoit] [autoit][/autoit] [autoit]

    $hPrinter = _OpenPrinter($cPrinter, $hPrinter, 0)
    IF $hPrinter = 0 Then
    MsgBox(0, "Error", "Could not open default printer. ")
    ENDIF

    [/autoit] [autoit][/autoit] [autoit]

    ;being called this way the function returns DEVMODE buffer required size
    $nBufsize = _DocumentProperties($hWindow, $hPrinter, $cPrinter, 0, 0, 0)
    $cDevmode = _StringRepeat(Chr(0), $nBufsize) ;

    [/autoit] [autoit][/autoit] [autoit]

    _SetOrient($DMORIENT_LANDSCAPE)
    _DocumentProperties($hWindow, $hPrinter, $cPrinter, $cDevmode, $cDevmode, $DM_IN_PROMPT+$DM_IN_BUFFER+$DM_OUT_BUFFER)

    [/autoit] [autoit][/autoit] [autoit]

    _ClosePrinter($hPrinter)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _SetOrient($nOrient)
    ; DEVMODE is adjusted programmatically
    ; DM_IN_PROMPT not used -- the dialog window is not shown
    LOCAL $dmFlags
    ;reading printer configuration
    _DocumentProperties($hWindow, $hPrinter, $cPrinter, $cDevmode, 0, $DM_OUT_BUFFER)
    $dmFlags = _buf2word(StringMid($cDevmode, $OFFS_ORIENT_FLAG, 4))
    $dmFlags = BitOR($dmFlags, $DM_ORIENTATION)
    $cDevmode = StringReplace($cDevmode, $OFFS_ORIENT_FLAG, 4, _num2dword($dmFlags))
    $cDevmode = StringReplace($cDevmode, $OFFS_ORIENT_VALUE, 2, _num2word($nOrient))
    ; using modified DEVMODE structure in the next call
    _DocumentProperties($hWindow, $hPrinter, $cPrinter,$cDevmode, $cDevmode, $DM_IN_BUFFER+$DM_OUT_BUFFER)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _buf2word($lcBuffer)
    $return = Asc(StringMid($lcBuffer, 1, 1))+Asc(StringMid($lcBuffer, 2, 1))*256
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _num2word($lnValue)

    [/autoit] [autoit][/autoit] [autoit]

    RETURN Chr(MOD($lnValue,256)) + CHR(INT($lnValue/256))

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _num2dword($lnValue)

    [/autoit] [autoit][/autoit] [autoit]

    Global Const $m0=256
    Global Const $m1=65536
    Global Const $m2=16777216

    [/autoit] [autoit][/autoit] [autoit]

    Local $b0, $b1, $b2, $b3

    [/autoit] [autoit][/autoit] [autoit]

    $b3 = Int($lnValue/$m2)
    $b2 = Int(($lnValue - ($b3*$m2))/$m1)
    $b1 = Int(($lnValue - ($b3*$m2) - ($b2*$m1))/$m0)
    $b0 = Mod($lnValue, $m0)

    [/autoit] [autoit][/autoit] [autoit]

    RETURN Chr($b0)+Chr($b1)+Chr($b2)+Chr($b3)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ;:::::::::::::::::::::::::::::::::::::::::::::::::::::::: Functions

    [/autoit] [autoit][/autoit] [autoit]

    Func _GetProfileStringA($cApp, $cKeyName, $cDefault, $cReturn, $nSize)
    $result = DllCall("kernel32.dll","dword","GetProfileStringA", "str", $cApp, "str", $cKeyName, "str", $cDefault, "str", $cReturn, "dword", $nSize)
    Return $result
    EndFunc

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _DocumentProperties($hParent,$hPrinter,$szPrinter, $pDevModeOut ,$pDevModeIn=0,$fMode=0)
    Local $err,$hwnd
    ;get a handle for property page parent
    If $hParent = 0 Then
    $hwnd = _WinAPI_GetDesktopWindow()
    Else
    $hwnd = $hParent
    EndIf
    Local $result = DllCall("winspool.drv","int","DocumentPropertiesW","hwnd",$hwnd,"handle",$hPrinter,"wstr",$szPrinter,"ptr",DllStructGetPtr($pDevModeOut),"ptr",$pDevModeIn,"dword",$fMode)
    $err = @error
    If $err Then Return SetError($err,0,0)
    Return $result[0]
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _DeviceCapabilities($objPrinterName, $objPrinterPortName, $fwCapability, $pOutput, $pDevMode)

    [/autoit] [autoit][/autoit] [autoit]

    If $pOutput = "" Then $pOutput = Chr(0)
    If $pDevMode = 0 Then $pDevMode = 0

    [/autoit] [autoit][/autoit] [autoit]

    $result = DllCall("winspool.drv", "long", "DeviceCapabilitiesA", _
    "str", $objPrinterName, "str", $objPrinterPortName, _
    "int", $fwCapability, "str", $pOutput, "long", $pDevMode)

    [/autoit] [autoit][/autoit] [autoit]

    Return $result[0]

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _OpenPrinter($pPrinter,ByRef $phPrinter,$pDefaults=-1)
    Local $err,$tPDF
    If $pDefaults = -1 Then
    $tPDF = DllStructCreate("ptr;ptr;ptr")
    DllStructSetData($tPDF,3,8)
    $pDefaults = DllStructGetPtr($tPDF)
    EndIf
    Local $t_pPrinter = DllStructCreate("ptr")
    $phPrinter = DllStructGetPtr($t_pPrinter)

    [/autoit] [autoit][/autoit] [autoit]

    Local $result = DllCall("winspool.drv","int","OpenPrinterW","wstr",$pPrinter,"ptr",$phPrinter,"ptr",$pDefaults)
    $err = @error
    $tPDF = 0
    If $err Then Return SetError($err,0,0)
    Return $result[0]
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _ClosePrinter($pPrinter)
    Local $err
    Local $result = DllCall("winspool.drv","int","ClosePrinter","handle",$pPrinter)
    $err = @error
    If $err Then Return SetError($err,0,0)
    Return $result[0]
    EndFunc
    ;::::::::::::::::::::::::::::::::::::::::::::::::::::::::

    [/autoit] [autoit][/autoit] [autoit]

    Func _Identify_Printers()
    Local $key, $default, $i = 1, $list, $name
    If @OSType = "WIN32_WINDOWS" Then
    $key = "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Print\Printers"
    $default = RegRead("HKEY_CURRENT_CONFIG\System\CurrentControlSet\Control\Print\Printers","Default")
    Else;WIN_NT type
    $key = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Printers"
    $default = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows","Device")
    $default = StringLeft($default, StringInStr($default,",")-1);remove info after comma...
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    ;;;$list = StringReplace($list, $default, '** ' & $default)

    [/autoit] [autoit][/autoit] [autoit]

    ; ENUMERATE LOCAL PRINTERS (AND ALSO 9x PRINTERS SHARED ON OTHER COMPUTERS)
    While 1
    ;#cs - enum bug workaround
    RegRead($key, "")
    If @error = 1 Then ExitLoop
    ;#ce
    Local $name = RegEnumKey($key, $i)
    If @error Then ExitLoop
    Local $port = "<" & RegRead($key & "\" & $name, "Port") & ">"
    ;************************************************************************modified
    If $name = $default Then
    $port = '* ' & $port

    [/autoit] [autoit][/autoit] [autoit]

    $res = $name &$port

    [/autoit] [autoit][/autoit] [autoit]

    EndIf
    ;***********************************************************************
    Local $driver = RegRead($key & "\" & $name, "Printer Driver")
    Local $shared = RegRead($key & "\" & $name, "Share Name")
    If $shared <> "" Then $shared = "$ " & $shared
    $list = $list & $port & " " & $name & " [" & $driver & "] " & $shared & @CRLF
    $i = $i + 1

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    ; ENUMERATE 2000/XP PRINTERS SHARED ON OTHER COMPUTERS
    If @OSType = "WIN_NT" Then
    Local $i = 1, $j = 1
    While 1
    ;#cs - enum bug workaround
    RegRead($key, "")
    If @error = 1 Then ExitLoop
    ;#ce
    Local $serverAddress = RegEnumKey($key, $i)
    If @error Then ExitLoop
    $j = 1
    While 1
    ;#cs - enum bug workaround
    RegRead($key & "\" & $serverAddress & "\Printers", "")
    If @error = 1 Then ExitLoop(2)
    ;#ce
    Local $networkedPrinter = RegEnumKey($key & "\" & $serverAddress & "\Printers", $j)
    If @error Then ExitLoop(2)
    $name = RegRead($key & "\" & $serverAddress & "\Printers\" & $networkedPrinter, "Name")
    Local $share = "<\\" & $serverAddress & "\" & RegRead($key & "\" & $serverAddress & "\Printers\" & $networkedPrinter, "Share Name") & ">"
    If $name = $default Then $share = '* ' & $share
    $list = $list & $share & " " & $name & " [" & $driver & "]" & @CRLF
    $j = $j + 1
    WEnd
    $i = $i + 1
    WEnd
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    If $list = "" Then $list = "No printers detected" & @CRLF
    ;Return $list ; default value
    Return $res
    EndFunc

    [/autoit]

    Einmal editiert, zuletzt von Real Shyfox (14. Mai 2011 um 17:25)

  • Hallo,

    • DEVMODE ist eine Struktur: http://msdn.microsoft.com/en-us/library/…28VS.85%29.aspx, Du machst einen String daraus. Auch wenn das Manipulieren per StringReplace() tatsächlich funktioniert, liefert DllStructGetPtr() für eine Stringvariable normalerweise den Wert 0.
    • Lege Deinen Code bitte in einen Spoiler
      Code
      [spoiler] ... [/spoiler]

      , der Thread bleibt dann übersichtlicher.

  • Ich werde versuchen, Ihre Ratschläge, obwohl ich neu in der DLL-Funktionen in AutoIt bin. Ich bin ein FoxPro-Programmierer und ein Autodidakt AutoIt und C + +.
    Vielen Dank!