|
-
August 7th, 2008, 03:15 AM
#1
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!
-
August 7th, 2008, 03:49 AM
#2
Re: Need VB conversion from C++
 Originally Posted by wizardnet
hi.
I have code was written on Win32API C++
That code is not written in C++.
Regards,
Paul McKenzie
-
August 9th, 2008, 07:59 PM
#3
Re: Need VB conversion from C++
 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|