Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. call winapi in c#

call winapi in c#

Scheduled Pinned Locked Moved C#
helpcsharpjson
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    Filip
    wrote on last edited by
    #1

    If have to use the api StartDocPrinter(handle,level,DOCINFO) in C# but getlast error = can't find module maybe there is a problem with the predefined structure DOCINFO. Is there anyone that has already used this kind of function. thanks Filip. ;P ;P ;P

    L 1 Reply Last reply
    0
    • F Filip

      If have to use the api StartDocPrinter(handle,level,DOCINFO) in C# but getlast error = can't find module maybe there is a problem with the predefined structure DOCINFO. Is there anyone that has already used this kind of function. thanks Filip. ;P ;P ;P

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      when is use this code in VB6.0 it works but when i try to import the functions via C# (dllimport) it doesn't work //VB6.0 code Option Explicit Private Type DOCINFO pDocName As String pOutputFile As String pDatatype As String End Type Private Declare Function ClosePrinter Lib "winspool.drv" (ByVal _ hPrinter As Long) As Long Private Declare Function EndDocPrinter Lib "winspool.drv" (ByVal _ hPrinter As Long) As Long Private Declare Function EndPagePrinter Lib "winspool.drv" (ByVal _ hPrinter As Long) As Long Private Declare Function OpenPrinter Lib "winspool.drv" Alias _ "OpenPrinterA" (ByVal pPrinterName As String, phPrinter As Long, _ ByVal pDefault As Long) As Long Private Declare Function StartDocPrinter Lib "winspool.drv" Alias _ "StartDocPrinterA" (ByVal hPrinter As Long, ByVal Level As Long, _ pDocInfo As DOCINFO) As Long Private Declare Function StartPagePrinter Lib "winspool.drv" (ByVal _ hPrinter As Long) As Long Private Declare Function WritePrinter Lib "winspool.drv" (ByVal _ hPrinter As Long, pBuf As Any, ByVal cdBuf As Long, _ pcWritten As Long) As Long Private Sub Command1_Click() Dim lhPrinter As Long Dim lReturn As Long Dim lpcWritten As Long Dim lDoc As Long Dim sWrittenData As String Dim MyDocInfo As DOCINFO lReturn = OpenPrinter(Printer.DeviceName, hPrinter, 0) If lReturn = 0 Then MsgBox "The Printer Name you typed wasn't recognized." Exit Sub End If MyDocInfo.pDocName = "AAAAAA" MyDocInfo.pOutputFile = vbNullString MyDocInfo.pDatatype = vbNullString lDoc = StartDocPrinter(lhPrinter, 1, MyDocInfo) Call StartPagePrinter(lhPrinter) sWrittenData = "How's that for Magic !!!!" & vbFormFeed lReturn = WritePrinter(lhPrinter, ByVal sWrittenData, _ Len(sWrittenData), lpcWritten) lReturn = EndPagePrinter(lhPrinter) lReturn = EndDocPrinter(lhPrinter) lReturn = ClosePrinter(lhPrinter) End Sub :confused: :confused: :confused: :confused:

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups