CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2008
    Posts
    11

    Need VB conversion from C++

    hi.

    I have code was written on Win32API C++

    please conversion it to VB.NET:


    [DllImport("user32.dll",SetLastError=true)]
    static extern IntPtr GetClipboardData(uint uFormat);
    [DllImport("user32.dll",SetLastError=true)]
    static extern bool OpenClipboard(IntPtr hWndNewOwner);
    [DllImport("user32.dll",SetLastError=true)]
    static extern bool CloseClipboard();
    [DllImport("user32.dll", SetLastError=true)]
    static extern uint RegisterClipboardFormatA(string lpszFormat);
    [DllImport("user32.dll",SetLastError=true)]
    static extern bool IsClipboardFormatAvailable(uint format);
    [DllImport("kernel32.dll",SetLastError=true)]
    static extern IntPtr GlobalLock(IntPtr hMem);
    [DllImport("kernel32.dll",SetLastError=true)]
    static extern uint GlobalSize(IntPtr hMem);
    [DllImport("kernel32.dll",SetLastError=true)]
    static extern IntPtr GlobalUnlock(IntPtr hMem);

    private void button1_Click(object sender, System.EventArgs e)
    {
    uint CF_HTML = RegisterClipboardFormatA("HTML Format");

    if (IsClipboardFormatAvailable(CF_HTML))
    {
    if(OpenClipboard(this.Handle))
    {
    IntPtr hGMem = GetClipboardData(CF_HTML) ;
    IntPtr pMFP = GlobalLock(hGMem) ;
    uint len=GlobalSize(hGMem);
    byte[] bytes=new byte[len];
    Marshal.Copy(pMFP,bytes, 0, (int)len);

    string strMFP =System.Text.Encoding.UTF8.GetString(bytes);
    this.textBox1.Text=strMFP;
    GlobalUnlock(hGMem) ;
    CloseClipboard() ;
    }
    }
    }


    Please help me, I need it very soon! please!

  2. #2
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Need VB conversion from C++

    Quote Originally Posted by wizardnet
    hi.

    I have code was written on Win32API C++
    That code is not written in C++.

    Regards,

    Paul McKenzie

  3. #3
    Join Date
    Nov 2006
    Posts
    146

    Re: Need VB conversion from C++

    Quote Originally Posted by wizardnet
    hi.

    I have code was written on Win32API C++

    please conversion it to VB.NET:


    [DllImport("user32.dll",SetLastError=true)]
    static extern IntPtr GetClipboardData(uint uFormat);
    [DllImport("user32.dll",SetLastError=true)]
    static extern bool OpenClipboard(IntPtr hWndNewOwner);
    [DllImport("user32.dll",SetLastError=true)]
    static extern bool CloseClipboard();
    [DllImport("user32.dll", SetLastError=true)]
    static extern uint RegisterClipboardFormatA(string lpszFormat);
    [DllImport("user32.dll",SetLastError=true)]
    static extern bool IsClipboardFormatAvailable(uint format);
    [DllImport("kernel32.dll",SetLastError=true)]
    static extern IntPtr GlobalLock(IntPtr hMem);
    [DllImport("kernel32.dll",SetLastError=true)]
    static extern uint GlobalSize(IntPtr hMem);
    [DllImport("kernel32.dll",SetLastError=true)]
    static extern IntPtr GlobalUnlock(IntPtr hMem);

    private void button1_Click(object sender, System.EventArgs e)
    {
    uint CF_HTML = RegisterClipboardFormatA("HTML Format");

    if (IsClipboardFormatAvailable(CF_HTML))
    {
    if(OpenClipboard(this.Handle))
    {
    IntPtr hGMem = GetClipboardData(CF_HTML) ;
    IntPtr pMFP = GlobalLock(hGMem) ;
    uint len=GlobalSize(hGMem);
    byte[] bytes=new byte[len];
    Marshal.Copy(pMFP,bytes, 0, (int)len);

    string strMFP =System.Text.Encoding.UTF8.GetString(bytes);
    this.textBox1.Text=strMFP;
    GlobalUnlock(hGMem) ;
    CloseClipboard() ;
    }
    }
    }


    Please help me, I need it very soon! please!
    Look like C# and not C++.
    If this post helps you out, please rate it!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured