Le Kevin dot com

photographic-poetic-musical horizon

12 Ca Khuc That Hay vao Mua Vong – Mua Giang Sinh

play  
display
back
play
next
refresh
00.00   /   00:00
Playlist
      
  1. Mua Dong Thuong Nho

    Thanh Xuan

  2.   
  3. Hai Mua Noel

    Bang Tam

  4.   
  5. Ta Ao Dem Noel

    Dan Nguyen

  6.   
  7. Nguoi Tinh Mua Dong

    Tuong Khua

  8.   
  9. Mua Dong Nam Ay

    My Huyen

  10.   
  11. Me Tinh Yeu

    Hop CA Asia

  12.   
  13. Troi Chua Muon Sang

    Phuong Hong Que

  14.   
  15. Bong Nho Giao Duong

    Tuong Nguyen

  16.   
  17. Mua Sao Sang

    Ngoc Huyen

  18.   
  19. Loi Me Nhan Nhu

    Tam Doan

  20.   
  21. Mot Ngay Mua Dong

    Y Phung

  22.   
  23. Mua Dong Ve Chua Em

    Dang The Luan

play  
display
back
play
next
refresh
00.00   /   00:00
Playlist
      
  1. Me Tinh Yeu

    Hop Ca

  2.   
  3. Long Me

    Hoang Oanh

  4.   
  5. Me Toi

    Nhu Quynh

  6.   
  7. Nuoc Mat Me Toi

    Anh Dung

  8.   
  9. Nua Dem Bien Gioi

    Hoang Oanh

  10.   
  11. Nho Me

    Dan Nguyen & Quoc Khanh

  12.   
  13. Loi Ve Dat Me

    Dang The Luon

  14.   
  15. Mung Tuoi Me

    Tuong Nguyen

  16.   
  17. Xuan Nay Con Ve Me O Dau

    Dang The Luan

  18.   
  19. Xuan Cua Me

    Tuong Nguyen

Zebra 450

Zebra 450

To send raw data to a printer from the Microsoft .NET Framework, your program must work with Win32 spooler functions. Through the .NET Framework, you can print by using PrintDocument, PrintController, and associated classes. However, with the .NET Framework, you cannot send preformatted printer-ready data to a printer.

You may have to send raw data to a printer to do the following:

  • Send escape sequences.
  • Download, and then use soft fonts.
  • Spool preprinted files.

To send these types and other types of raw data to a printer, your code must work with Win32 Spooler Application Programmer Interfaces (APIs). The following code shows how to read the contents of a preformatted file into memory, and then send those bytes to the printer by using WritePrinter.

Below is the test code to raw print with ZPL on Zebra 450 Printer; the custom info must be on separate line for printer to be able to translate.


Main method

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Printing;
using System.Linq;
using System.Text;
using System.IO;
using System.Windows.Forms;
using System.Runtime.InteropServices;
 
public void PrintLabel()
{
            StringBuilder label = new StringBuilder();
            label.AppendLine("^XA");
            label.AppendLine("^FO600,110");
            label.AppendLine("^FO50,50^ADN,30,12^FDSHIP TO:^FS");
            label.AppendLine("^FO50,100^A0N,30,30^FD");
            label.AppendLine("ERICA RIVERA");
            label.AppendLine("^FS~NAME^FS");
            label.AppendLine("^FO50,140^A0N,30,30^FD");
            label.AppendLine("BETHUNE SCHOOL");
            label.AppendLine("^FS~COMPANY^FS");
            label.AppendLine("^FO50,180^A0N,30,30^FD");
            label.AppendLine("166 S FRUIT AVE");
            label.AppendLine("^FS");
            label.AppendLine("^FO50,220^A0N,30,30^FD^FS~REF1^FS");
            label.AppendLine("^FO50,250^A0N,30,40^FD");
            label.AppendLine("FRESNO CA 93706-2899");
            label.AppendLine("^FS~CITY ~STATE ~ZIP^FS");
            label.AppendLine("^FO50,325^ADN,30,12^FDORDER #:^FS");
            label.AppendLine("^FO160,325^A0N,30,50^FD");
            label.AppendLine("P045722701017");
            label.AppendLine("^FSFDORDER #: ~ORDERNO^FS");
            label.AppendLine("^FO50,400^ADN,30,12^FD");
            label.AppendLine("GROUND SERVICE");
            label.AppendLine("^FS~SHIPMETHOD^FS");
            label.AppendLine("^FO650,400^ADN,30,12^FD");
            label.AppendLine("BOX 1 of 2");
            label.AppendLine("^FSBOX: ~BOXCNT^FS");
            label.AppendLine("^FO50,450^B3^BY3N,N,100,Y,N,^FD700830865038^FS");
            label.AppendLine("^XZ");
 
            // Allow the user to select a printer.
            PrintDialog pd = new PrintDialog();
            pd.UseEXDialog = true;
            pd.PrinterSettings = new PrinterSettings();
            if (DialogResult.OK == pd.ShowDialog(this))
            {
                // Send a printer-specific to the printer.
                RawPrinterHelper.SendStringToPrinter(pd_KLE.PrinterSettings.PrinterName, label.ToString());
            }
            return;
}

RawPrinterHelper Class

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Runtime.InteropServices;
 
    public class RawPrinterHelper
    {
        // Structure and API declarions:
        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
        public class DOCINFOA
        {
            [MarshalAs(UnmanagedType.LPStr)]
            public string pDocName;
            [MarshalAs(UnmanagedType.LPStr)]
            public string pOutputFile;
            [MarshalAs(UnmanagedType.LPStr)]
            public string pDataType;
        }
        [DllImport("winspool.Drv", EntryPoint = "OpenPrinterA", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
        public static extern bool OpenPrinter([MarshalAs(UnmanagedType.LPStr)] string szPrinter, out IntPtr hPrinter, IntPtr pd);
 
        [DllImport("winspool.Drv", EntryPoint = "ClosePrinter", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
        public static extern bool ClosePrinter(IntPtr hPrinter);
 
        [DllImport("winspool.Drv", EntryPoint = "StartDocPrinterA", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
        public static extern bool StartDocPrinter(IntPtr hPrinter, Int32 level, [In, MarshalAs(UnmanagedType.LPStruct)] DOCINFOA di);
 
        [DllImport("winspool.Drv", EntryPoint = "EndDocPrinter", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
        public static extern bool EndDocPrinter(IntPtr hPrinter);
 
        [DllImport("winspool.Drv", EntryPoint = "StartPagePrinter", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
        public static extern bool StartPagePrinter(IntPtr hPrinter);
 
        [DllImport("winspool.Drv", EntryPoint = "EndPagePrinter", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
        public static extern bool EndPagePrinter(IntPtr hPrinter);
 
        [DllImport("winspool.Drv", EntryPoint = "WritePrinter", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
        public static extern bool WritePrinter(IntPtr hPrinter, IntPtr pBytes, Int32 dwCount, out Int32 dwWritten);
 
        // SendBytesToPrinter()
        // When the function is given a printer name and an unmanaged array
        // of bytes, the function sends those bytes to the print queue.
        // Returns true on success, false on failure.
        public static bool SendBytesToPrinter(string szPrinterName, IntPtr pBytes, Int32 dwCount)
        {
            Int32 dwError = 0, dwWritten = 0;
            IntPtr hPrinter = new IntPtr(0);
            DOCINFOA di = new DOCINFOA();
            bool bSuccess = false; // Assume failure unless you specifically succeed.
 
            di.pDocName = "My C#.NET RAW Document";
            di.pDataType = "RAW";
 
            // Open the printer.
            if (OpenPrinter(szPrinterName.Normalize(), out hPrinter, IntPtr.Zero))
            {
                // Start a document.
                if (StartDocPrinter(hPrinter, 1, di))
                {
                    // Start a page.
                    if (StartPagePrinter(hPrinter))
                    {
                        // Write your bytes.
                        bSuccess = WritePrinter(hPrinter, pBytes, dwCount, out dwWritten);
                        EndPagePrinter(hPrinter);
                    }
                    EndDocPrinter(hPrinter);
                }
                ClosePrinter(hPrinter);
            }
            // If you did not succeed, GetLastError may give more information
            // about why not.
            if (bSuccess == false)
            {
                dwError = Marshal.GetLastWin32Error();
            }
            return bSuccess;
        }
 
        public static bool SendFileToPrinter(string szPrinterName, string szFileName)
        {
            // Open the file.
            FileStream fs = new FileStream(szFileName, FileMode.Open);
            // Create a BinaryReader on the file.
            BinaryReader br = new BinaryReader(fs);
            // Dim an array of bytes big enough to hold the file's contents.
            Byte[] bytes = new Byte[fs.Length];
            bool bSuccess = false;
            // Your unmanaged pointer.
            IntPtr pUnmanagedBytes = new IntPtr(0);
            int nLength;
 
            nLength = Convert.ToInt32(fs.Length);
            // Read the contents of the file into the array.
            bytes = br.ReadBytes(nLength);
            // Allocate some unmanaged memory for those bytes.
            pUnmanagedBytes = Marshal.AllocCoTaskMem(nLength);
            // Copy the managed byte array into the unmanaged array.
            Marshal.Copy(bytes, 0, pUnmanagedBytes, nLength);
            // Send the unmanaged bytes to the printer.
            bSuccess = SendBytesToPrinter(szPrinterName, pUnmanagedBytes, nLength);
            // Free the unmanaged memory that you allocated earlier.
            Marshal.FreeCoTaskMem(pUnmanagedBytes);
            return bSuccess;
        }
        public static bool SendStringToPrinter(string szPrinterName, string szString)
        {
            IntPtr pBytes;
            Int32 dwCount;
            // How many characters are in the string?
            dwCount = szString.Length;
            // Assume that the printer is expecting ANSI text, and then convert
            // the string to ANSI text.
            pBytes = Marshal.StringToCoTaskMemAnsi(szString);
            // Send the converted ANSI string to the printer.
            SendBytesToPrinter(szPrinterName, pBytes, dwCount);
            Marshal.FreeCoTaskMem(pBytes);
            return true;
        }
    }
Printed Sample Label

Printed Sample Label

References:

EPL Programming Guide in PDF

ZPL II Programming Guide in PDF

http://support.microsoft.com/kb/322091

https://ups.zebra.com/UPSZebraWeb/support/product-detail-ZP450.html

The Windows Internet (WinINet) application programming interface (API) enables applications to interact with FTP, and HTTP protocols to access Internet resources. As standards evolve, these functions handle the changes in underlying protocols, enabling them to maintain consistent behavior.

Sample code of PostMethod.cls class  in VB6

Option Explicit
 
'*** DECLARATIONS FOUND IN WININET.H ***
Private Declare Function InternetCloseHandle Lib "wininet.dll" (ByVal hInet As Long) As Integer
Private Declare Function InternetConnect Lib "wininet.dll" Alias "InternetConnectA" (ByVal hInternetSession As Long, ByVal sServerName As String, ByVal nServerPort As Integer, ByVal sUserName As String, ByVal sPassword As String, ByVal lService As Long, ByVal lFlags As Long, ByVal lContext As Long) As Long
Private Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" (ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String, ByVal sProxyBypass As String, ByVal lFlags As Long) As Long
Private Declare Function InternetQueryDataAvailable Lib "wininet.dll" (ByVal hHttpRequest As Long, ByRef lpdwNumberOfBytesAvailable As Long, ByVal dwFlags As Long, ByVal dwContext As Long) As Long
Private Declare Function InternetReadFile Lib "wininet" (ByVal hFile As Long, ByVal sBuffer As String, ByVal lNumBytesToRead As Long, lNumberOfBytesRead As Long) As Integer
Private Declare Function InternetQueryOption Lib "wininet.dll" Alias "InternetQueryOptionA" (ByVal hHttpRequest As Long, ByVal dwOption As Long, lpBuffer As Any, ByRef dwBufferLength As Long) As Long
Private Declare Function InternetSetOption Lib "wininet.dll" Alias "InternetSetOptionA" (ByVal hHttpRequest As Long, ByVal dwOption As Long, lpBuffer As Any, ByVal dwBufferLength As Long) As Long
Private Declare Function HttpAddRequestHeaders Lib "wininet.dll" Alias "HttpAddRequestHeadersA" (ByVal hInternetSession As Long, ByVal lpHeaders As String, ByVal lHeadersLength As Long, ByVal lModifiers As Long) As Long
Private Declare Function HttpOpenRequest Lib "wininet.dll" Alias "HttpOpenRequestA" (ByVal hHttpSession As Long, ByVal sVerb As String, ByVal sObjectName As String, ByVal sVersion As String, ByVal sReferer As String, ByVal sAcceptTypes As String, ByVal lFlags As Long, ByVal lContext As Long) As Long
Private Declare Function HttpQueryInfo Lib "wininet.dll" Alias "HttpQueryInfoA" (ByVal hHttpRequest As Long, ByVal lInfoLevel As Long, ByRef sBuffer As Any, ByRef lBufferLength As Long, ByRef lIndex As Long) As Long
Private Declare Function HttpSendRequest Lib "wininet.dll" Alias "HttpSendRequestA" (ByVal hHttpRequest As Long, ByVal sHeaders As String, ByVal lHeadersLength As Long, ByVal sOptional As String, ByVal lOptionalLength As Long) As Long
'**********************************************
' Constants for InternetOpen()
'**********************************************
Private Const INTERNET_OPEN_TYPE_PRECONFIG = 0
'**********************************************
' Constants for InternetConnect()
'**********************************************
Private Const INTERNET_DEFAULT_HTTP_PORT = 80
Private Const INTERNET_DEFAULT_HTTPS_PORT = 443
Private Const INTERNET_SERVICE_HTTP = 3
'**********************************************
' Constants for HttpOpenRequest()
'**********************************************
Private Const INTERNET_FLAG_RELOAD = &H80000000
Private Const INTERNET_FLAG_NO_CACHE_WRITE = &H4000000
Private Const INTERNET_FLAG_PRAGMA_NOCACHE = &H100
Private Const INTERNET_FLAG_NO_COOKIES = &H80000
Private Const INTERNET_FLAG_SECURE = &H800000
'**********************************************
' Constants for InternetQueryOption() or InternetSetOption()
'**********************************************
Private Const INTERNET_OPTION_CONNECT_TIMEOUT = 2
Private Const INTERNET_OPTION_SEND_TIMEOUT = 5
Private Const INTERNET_OPTION_RECEIVE_TIMEOUT = 6
Private Const INTERNET_OPTION_SECURITY_FLAGS = 31
Private Const SECURITY_FLAG_IGNORE_UNKNOWN_CA = &H100
'**********************************************
' Constants for HttpAddRequestHeaders()
'**********************************************
Private Const HTTP_ADDREQ_FLAG_ADD_IF_NEW = &H10000000
Private Const HTTP_ADDREQ_FLAG_ADD = &H20000000
Private Const HTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA = &H40000000
Private Const HTTP_ADDREQ_FLAG_COALESCE_WITH_SEMICOLON = &H1000000
Private Const HTTP_ADDREQ_FLAG_REPLACE = &H80000000
Private Const ERROR_INSUFFICIENT_BUFFER = 122
 
Public Enum enumPostHeader
    HTTP_QUERY_ACCEPT = 24
    HTTP_QUERY_ACCEPT_CHARSET = 25
    HTTP_QUERY_ACCEPT_ENCODING = 26
    HTTP_QUERY_ACCEPT_LANGUAGE = 27
    HTTP_QUERY_ACCEPT_RANGES = 42
    HTTP_QUERY_AGE = 48
    HTTP_QUERY_ALLOW = 7
    HTTP_QUERY_AUTHORIZATION = 28
    HTTP_QUERY_CACHE_CONTROL = 49
    HTTP_QUERY_CONNECTION = 23
    HTTP_QUERY_CONTENT_BASE = 50
    HTTP_QUERY_CONTENT_DESCRIPTION = 4
    HTTP_QUERY_CONTENT_DISPOSITION = 47
    HTTP_QUERY_CONTENT_ENCODING = 29
    HTTP_QUERY_CONTENT_ID = 3
    HTTP_QUERY_CONTENT_LANGUAGE = 6
    HTTP_QUERY_CONTENT_LENGTH = 5
    HTTP_QUERY_CONTENT_LOCATION = 51
    HTTP_QUERY_CONTENT_MD5 = 52
    HTTP_QUERY_CONTENT_RANGE = 53
    HTTP_QUERY_CONTENT_TRANSFER_ENCODING = 2
    HTTP_QUERY_CONTENT_TYPE = 1
    HTTP_QUERY_COOKIE = 44
    HTTP_QUERY_COST = 15
    HTTP_QUERY_CUSTOM = 65535
    HTTP_QUERY_DATE = 9
    HTTP_QUERY_DERIVED_FROM = 14
    HTTP_QUERY_ECHO_HEADERS = 73
    HTTP_QUERY_ECHO_HEADERS_CRLF = 74
    HTTP_QUERY_ECHO_REPLY = 72
    HTTP_QUERY_ECHO_REQUEST = 71
    HTTP_QUERY_ETAG = 54
    HTTP_QUERY_EXPECT = 68
    HTTP_QUERY_EXPIRES = 10
    HTTP_QUERY_FORWARDED = 30
    HTTP_QUERY_FROM = 31
    HTTP_QUERY_HOST = 55
    HTTP_QUERY_IF_MATCH = 56
    HTTP_QUERY_IF_MODIFIED_SINCE = 32
    HTTP_QUERY_IF_NONE_MATCH = 57
    HTTP_QUERY_IF_RANGE = 58
    HTTP_QUERY_IF_UNMODIFIED_SINCE = 59
    HTTP_QUERY_LAST_MODIFIED = 11
    HTTP_QUERY_LINK = 16
    HTTP_QUERY_LOCATION = 33
    HTTP_QUERY_MAX = 78
    HTTP_QUERY_MAX_FORWARDS = 60
    HTTP_QUERY_MESSAGE_ID = 12
    HTTP_QUERY_MIME_VERSION = 0
    HTTP_QUERY_ORIG_URI = 34
    HTTP_QUERY_PRAGMA = 17
    HTTP_QUERY_PROXY_AUTHENTICATE = 41
    HTTP_QUERY_PROXY_AUTHORIZATION = 61
    HTTP_QUERY_PROXY_CONNECTION = 69
    HTTP_QUERY_PUBLIC = 8
    HTTP_QUERY_RANGE = 62
    HTTP_QUERY_RAW_HEADERS = 21
    HTTP_QUERY_RAW_HEADERS_CRLF = 22
    HTTP_QUERY_REFERER = 35
    HTTP_QUERY_REFRESH = 46
    HTTP_QUERY_REQUEST_METHOD = 45
    HTTP_QUERY_RETRY_AFTER = 36
    HTTP_QUERY_SERVER = 37
    HTTP_QUERY_SET_COOKIE = 43
    HTTP_QUERY_STATUS_CODE = 19
    HTTP_QUERY_STATUS_TEXT = 20
    HTTP_QUERY_TITLE = 38
    HTTP_QUERY_TRANSFER_ENCODING = 63
    HTTP_QUERY_UNLESS_MODIFIED_SINCE = 70
    HTTP_QUERY_UPGRADE = 64
    HTTP_QUERY_URI = 13
    HTTP_QUERY_USER_AGENT = 39
    HTTP_QUERY_VARY = 65
    HTTP_QUERY_VERSION = 18
    HTTP_QUERY_VIA = 66
    HTTP_QUERY_WARNING = 67
    HTTP_QUERY_WWW_AUTHENTICATE = 40
End Enum
 
Private Const CONNECTION_TIMEOUT_MILLIS As Long = 60000
 
Private m_sURLDomain As String
Private m_sURLPort As String
Private m_sURLPath As String
Private m_bURLSSL As Boolean
Private m_sPOSTData As String
Private m_hInetSession As Long
Private m_hInetConnect As Long
Private m_hInetRequest As Long
Private m_sHttpMethod As String
 
Public Property Let PostParameters(ByVal sData As String)
    m_sPOSTData = sData
End Property
 
Public Property Get PostParameters() As String
    PostParameters = m_sPOSTData
End Property
 
Public Function OpenRequest(ByVal sURL As String, _
                            Optional ByVal sHttpMethod As String = "POST", _
                            Optional ByVal sUserName As String = vbNullString, _
                            Optional ByVal sPassword As String = vbNullString, _
                            Optional ByRef sErrorMsg As Variant) As Boolean
 
    m_sPOSTData = ""
    m_sHttpMethod = sHttpMethod
    If Not CrackURL(sURL) Then Exit Function
 
    m_hInetSession = InternetOpen("Http Client", _
                                  INTERNET_OPEN_TYPE_PRECONFIG, _
                                  vbNullString, _
                                  vbNullString, _
                                  0)
    If m_hInetSession <= 0 Then
        sErrorMsg = "InternetOpen() failed (System Error " & Err.LastDllError & ")"
        GoTo EXIT_LABEL
    End If
 
    m_hInetConnect = InternetConnect(m_hInetSession, _
                                     m_sURLDomain, _
                                     m_sURLPort, _
                                     sUserName, _
                                     sPassword, _
                                     INTERNET_SERVICE_HTTP, _
                                     0, _
                                     0)
    If m_hInetSession <= 0 Then
        sErrorMsg = "InternetConnect() failed (System Error " & Err.LastDllError & ")"
        GoTo EXIT_LABEL
    End If
 
    Dim lFlags As Long
    lFlags = (INTERNET_FLAG_NO_COOKIES Or INTERNET_FLAG_RELOAD Or INTERNET_FLAG_NO_CACHE_WRITE)
    If m_bURLSSL Then lFlags = (lFlags Or INTERNET_FLAG_SECURE)
 
    m_hInetRequest = HttpOpenRequest(m_hInetConnect, _
                                     sHttpMethod, _
                                     m_sURLPath, _
                                     "HTTP/1.0", _
                                     vbNullString, _
                                     vbNullString, _
                                     lFlags, _
                                     0)
    If m_hInetRequest <= 0 Then         sErrorMsg = "HttpOpenRequest() failed (System Error " & Err.LastDllError & ")"         GoTo EXIT_LABEL     End If          If Not CBool(InternetSetOption(m_hInetRequest, INTERNET_OPTION_CONNECT_TIMEOUT, CONNECTION_TIMEOUT_MILLIS, 4)) Then         sErrorMsg = "InternetSetOption(INTERNET_OPTION_CONNECT_TIMEOUT) failed (System Error " & Err.LastDllError & ")"         GoTo EXIT_LABEL     End If          If Not CBool(InternetSetOption(m_hInetRequest, INTERNET_OPTION_SEND_TIMEOUT, CONNECTION_TIMEOUT_MILLIS, 4)) Then         sErrorMsg = "InternetSetOption(INTERNET_OPTION_SEND_TIMEOUT) failed (System Error " & Err.LastDllError & ")"         GoTo EXIT_LABEL     End If          If Not CBool(InternetSetOption(m_hInetRequest, INTERNET_OPTION_RECEIVE_TIMEOUT, CONNECTION_TIMEOUT_MILLIS, 4)) Then         sErrorMsg = "InternetSetOption(INTERNET_OPTION_RECEIVE_TIMEOUT) failed (System Error " & Err.LastDllError & ")"         GoTo EXIT_LABEL     End If     If sHttpMethod = "POST" Then         If Not AddHeader("Content-Type", "application/x-www-form-urlencoded") Then             sErrorMsg = "AddHeader('Content-Type') failed"             GoTo EXIT_LABEL         End If     End If     If m_bURLSSL Then         Dim lBuffer As Long         Call InternetQueryOption(m_hInetRequest, INTERNET_OPTION_SECURITY_FLAGS, lFlags, lBuffer)         lFlags = lFlags Or SECURITY_FLAG_IGNORE_UNKNOWN_CA         Call InternetSetOption(m_hInetRequest, INTERNET_OPTION_SECURITY_FLAGS, lFlags, lBuffer)     End If     OpenRequest = True EXIT_LABEL: End Function Public Function AddHeader(ByVal sName As String, _                           ByVal sValue As String) As Boolean     Dim sHeaderFmt As String     sHeaderFmt = Trim(sName) & ": " & Trim(sValue) & vbCrLf     AddHeader = CBool(HttpAddRequestHeaders(m_hInetRequest, _                                             sHeaderFmt, _                                             Len(sHeaderFmt), _                                             HTTP_ADDREQ_FLAG_ADD Or HTTP_ADDREQ_FLAG_REPLACE)) End Function Public Function AddPOSTParameter(ByVal Name As String, ByVal Value As String) As Boolean     Dim sParam As String     Name = Trim(Name)     Value = Trim(Value)     If m_sHttpMethod = "POST" Then Value = UrlEncode(Value)     If Len(Name) > 0 Then
        sParam = Name & "=" & Value
    Else
        sParam = Value
    End If
 
    If Len(m_sPOSTData) = 0 Then
        m_sPOSTData = sParam
    Else
        m_sPOSTData = m_sPOSTData & "&" & sParam
    End If
    AddPOSTParameter = True
End Function
 
Public Function Execute() As Boolean
    If Len(m_sPOSTData) > 0 Then
        Call AddHeader("Content-Length", Len(m_sPOSTData))
        Execute = CBool(HttpSendRequest(m_hInetRequest, vbNullString, 0, m_sPOSTData, Len(m_sPOSTData)))
    Else
        Execute = CBool(HttpSendRequest(m_hInetRequest, vbNullString, 0, vbNullString, 0))
    End If
End Function
 
Public Function GetResponseAsString() As String
On Error GoTo ErrHandler
    Dim sBody As String
    Dim sBuffer As String
    Dim lBytesRead As Long
    Do
        sBuffer = Space$(4048)
        InternetReadFile m_hInetRequest, sBuffer, Len(sBuffer), lBytesRead
        If lBytesRead <= 0 Then Exit Do         sBody = sBody & Left$(sBuffer, lBytesRead)     Loop     GetResponseAsString = sBody     Exit Function ErrHandler:     GetResponseAsString = "" End Function Public Function GetResponseHeader(ByVal lHeaderType As enumPostHeader) As String On Error GoTo ErrHandler     Dim sValue As String     Dim lBytesRead As Long     Dim lHeaderIndex As Long     Dim bSuccess As Boolean     sValue = String(2000, Chr$(0))     lBytesRead = Len(sValue)     bSuccess = CBool(HttpQueryInfo(m_hInetRequest, lHeaderType, ByVal sValue, lBytesRead, lHeaderIndex))     If bSuccess And lBytesRead > 0 Then
        GetResponseHeader = Left$(sValue, InStr(1, sValue, Chr$(0)) - 1)
    End If
    Exit Function
 
ErrHandler:
End Function
 
Private Function CrackURL(ByVal strURL As String) As Boolean
    Dim intPos As Integer
    Dim strProtocol As String
 
    m_sURLDomain = ""
    m_sURLPort = ""
    m_sURLPath = ""
    m_bURLSSL = False
 
    ' search for double forward slash and remove protocol prefix
    intPos = InStr(1, strURL, "//")
    If intPos > 0 Then
        strProtocol = Left$(strURL, intPos - 1)
        strURL = Mid$(strURL, intPos + 2)
    End If
 
    m_bURLSSL = (InStr(LCase(strProtocol), "https") > 0)
 
    ' split the URL into domain and path using the first forward slash found
    ' If no slash is found, then the url is the domain only
    intPos = InStr(1, strURL, "/")
    If intPos > 0 Then
        m_sURLDomain = Left$(strURL, intPos - 1)
        m_sURLPath = Mid$(strURL, intPos + 1)
    Else
        m_sURLDomain = strURL
    End If
 
    ' Now see if a port is attached to the domain; split if found
    intPos = InStr(1, m_sURLDomain, ":")
    If intPos > 0 Then
        m_sURLPort = Mid$(m_sURLDomain, intPos + 1)
        m_sURLDomain = Left$(m_sURLDomain, intPos - 1)
    Else
        m_sURLPort = IIf(m_bURLSSL, INTERNET_DEFAULT_HTTPS_PORT, INTERNET_DEFAULT_HTTP_PORT)
    End If
    CrackURL = True
End Function
 
Private Function TrimString(ByVal s As String) As String
    TrimString = Left$(s, InStr(1, s, Chr$(0)) - 1)
End Function
 
Private Function UrlEncode(sText As String) As String
    Dim sResult As String
    Dim sFinal As String
    Dim sChar As String
    Dim i As Long
 
    sResult = ""
    sFinal = ""
    For i = 1 To Len(sText)
        sChar = Mid$(sText, i, 1)
        If InStr(1, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", sChar) <> 0 Then
            sResult = sResult & sChar
        ElseIf sChar = " " Then
            sResult = sResult & "+"
        ElseIf sChar = vbCr Or sChar = vbLf Or sChar = vbCrLf Then
        Else
            sResult = sResult & "%" & Hex(Asc(sChar))
        End If
        If Len(sResult) >= 1000 Then
            sFinal = sFinal & sResult
            sResult = ""
        End If
    Next
    UrlEncode = sFinal & sResult
End Function
 
Public Sub CloseConnection()
On Error GoTo ERROR_HANDLER
    If m_hInetRequest > 0 Then Call InternetCloseHandle(m_hInetRequest)
    If m_hInetConnect > 0 Then Call InternetCloseHandle(m_hInetConnect)
    If m_hInetSession > 0 Then Call InternetCloseHandle(m_hInetSession)
    m_hInetRequest = 0
    m_hInetConnect = 0
    m_hInetSession = 0
    m_sPOSTData = ""
    m_sURLDomain = ""
    m_sURLPort = ""
    m_sURLPath = ""
    m_bURLSSL = False
ERROR_HANDLER:
End Sub
 
Private Sub Class_Terminate()
    Call CloseConnection
End Sub

via: http://msdn.microsoft.com/en-us/library/windows/desktop/aa385483%28v=vs.85%29.aspx

http://www.holmessoft.co.uk/homepage/WininetVB.htm

 

Download Comdlg32.zip

Extract comdlg32.ocx to Windows\SysWOW64 folder

CMD as administrator and register as: regsvr32  %Systemroot%\SysWOW64\comdlg32.ocx

To install this COM component on your Visual Studio .NET computer:

  1. Create a new folder named Legacy on your hard drive.
  2. Copy PhysServer.dll to the Legacy folder.
  3. Open a command prompt window and type:
regsvr32 c:\Legacy\PhysServer.dll

Use TLBIMP to Create an Assembly

 

  • To open a Visual Studio .NET command prompt window, click Start, click Programs, click Microsoft Visual Studio .NET 7.0, click Visual Studio .NET Tools, and then click Visual Studio .NET Command Prompt.
  • Change to the \Legacy directory.
  • At the command prompt, type:
tlbimp PhysServer.dll /out:NETPhysServer.dll

OR Using the COM Component Directly
http://msdn.microsoft.com/en-us/library/ms973800.aspx