473,467 Members | 1,570 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to write in VB.NET from this code?

The following is a c# code about using browser helper object(BHO)
anyone know in VB.NET?

[
ComVisible(true),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown ),
Guid("FC4801A3-2BA9-11CF-A229-00AA003D7352")
]
public interface IObjectWithSite
{
[PreserveSig]
int SetSite([MarshalAs(UnmanagedType.IUnknown)]object site);
[PreserveSig]
int GetSite(ref Guid guid, out IntPtr ppvSite);
}

Thanks a lot.

Feb 13 '07 #1
9 3930
On 2007-02-13, Cylix <cy*******@gmail.comwrote:
The following is a c# code about using browser helper object(BHO)
anyone know in VB.NET?

[
ComVisible(true),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown ),
Guid("FC4801A3-2BA9-11CF-A229-00AA003D7352")
]
public interface IObjectWithSite
{
[PreserveSig]
int SetSite([MarshalAs(UnmanagedType.IUnknown)]object site);
[PreserveSig]
int GetSite(ref Guid guid, out IntPtr ppvSite);
}

Thanks a lot.
hmmm, something like:

< _
ComVisible(true), _
InterfaceType(ComInterfaceType.InterfaceIsIUnknown ), _
Guid("FC4801A3-2BA9-11CF-A229-00AA003D7352") _
>
Public Interface IObjectWithSite
<PreserveSig_
Function SetSite _
(<MarshalAs(UnmanagedType.IUnknown)site As Object) As Integer

<PreserveSig_
Function GetSite _
(ByRef guid As Guid, ByRef ppvSite As IntPtr) As Integer
End Interface

Anyway, that should be fairly close :)

--
Tom Shelton
Feb 13 '07 #2
eat shit c# fag

MS didn't need to invent your langauge; fuck you and fuck C#

Feb 13 '07 #3
Tom,

You old VB6 guys show in fact often a lack of that.

You all are experts in taken all kind of interfaces, Api's or whatever for
what is now mostly an easier to maintenance class not in the language but in
the .Net and therefore for everybody.

It was just the thought I wanted to deal with you.
(And tickling for a reaction from Herfried)

:-)

Cor

"Tom Shelton" <to*********@comcastXXXXXXX.netschreef in bericht
news:zZ******************************@comcast.com. ..
On 2007-02-13, Cylix <cy*******@gmail.comwrote:
>The following is a c# code about using browser helper object(BHO)
anyone know in VB.NET?

[
ComVisible(true),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown ),
Guid("FC4801A3-2BA9-11CF-A229-00AA003D7352")
]
public interface IObjectWithSite
{
[PreserveSig]
int SetSite([MarshalAs(UnmanagedType.IUnknown)]object site);
[PreserveSig]
int GetSite(ref Guid guid, out IntPtr ppvSite);
}

Thanks a lot.

hmmm, something like:

< _
ComVisible(true), _
InterfaceType(ComInterfaceType.InterfaceIsIUnknown ), _
Guid("FC4801A3-2BA9-11CF-A229-00AA003D7352") _
>>
Public Interface IObjectWithSite
<PreserveSig_
Function SetSite _
(<MarshalAs(UnmanagedType.IUnknown)site As Object) As Integer

<PreserveSig_
Function GetSite _
(ByRef guid As Guid, ByRef ppvSite As IntPtr) As Integer
End Interface

Anyway, that should be fairly close :)

--
Tom Shelton

Feb 13 '07 #4
On 2007-02-13, Cor Ligthert [MVP] <no************@planet.nlwrote:
Tom,

You old VB6 guys show in fact often a lack of that.
Lack of what? I'm not sure I'm following here.
You all are experts in taken all kind of interfaces, Api's or whatever for
what is now mostly an easier to maintenance class not in the language but in
the .Net and therefore for everybody.
Are BHO's implemented in the framework? They maybe, but I'm not aware of
them.
It was just the thought I wanted to deal with you.
(And tickling for a reaction from Herfried)

:-)

Cor
Sorry Cor, I'm not following the meaning of your post. All I did was try and
convert his C# code to VB.NET. I'm not certain it was 100% accurate - I'm not
in a mind to fully test it, but I think it was pretty close for an on the fly
conversion :)

--
Tom Shelton
Feb 13 '07 #5
Tom,

When it is about using this kind of code
ComVisible(true),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown ),
Guid("FC4801A3-2BA9-11CF-A229-00AA003D7352")
It are always you, Herfried, in past Armin, and some others I cannot get the
name from our Scandinavian friend, who answer this. But one thing they have
in common almost forever formely VB6 people.

That is all.

Cor
"Tom Shelton" <to*********@comcastXXXXXXX.netschreef in bericht
news:a8******************************@comcast.com. ..
On 2007-02-13, Cor Ligthert [MVP] <no************@planet.nlwrote:
>Tom,

You old VB6 guys show in fact often a lack of that.

Lack of what? I'm not sure I'm following here.
>You all are experts in taken all kind of interfaces, Api's or whatever
for
what is now mostly an easier to maintenance class not in the language but
in
the .Net and therefore for everybody.

Are BHO's implemented in the framework? They maybe, but I'm not aware of
them.
>It was just the thought I wanted to deal with you.
(And tickling for a reaction from Herfried)

:-)

Cor

Sorry Cor, I'm not following the meaning of your post. All I did was try
and
convert his C# code to VB.NET. I'm not certain it was 100% accurate - I'm
not
in a mind to fully test it, but I think it was pretty close for an on the
fly
conversion :)

--
Tom Shelton

Feb 13 '07 #6
Cor,

"Cor Ligthert [MVP]" <no************@planet.nlschrieb:
When it is about using this kind of code
> ComVisible(true),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown ),
Guid("FC4801A3-2BA9-11CF-A229-00AA003D7352")

It are always you, Herfried, in past Armin, and some others I cannot get
the name from our Scandinavian friend, who answer this. But one thing they
have in common almost forever formely VB6 people.
That's true. Many "young" developers who started with ".NET Framework and
C#" don't have the background knowledge about COM/Win32 programming.
However, there are certain things which can unfortunately only archieved
using p/invoke and COM interop, like BHOs.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Feb 13 '07 #7
Thanks Tom,
I do really weak in concept of COM.
Please give me further help.

'------------------- My Code Now ----------------------------------
Public Class BHO

< _
ComVisible(true), _
InterfaceType(ComInterfaceType.InterfaceIsIUnknown ), _
Guid("FC4801A3-2BA9-11CF-A229-00AA003D7352") _
Public Interface IObjectWithSite
<PreserveSig()_
Function SetSite _
(<MarshalAs(UnmanagedType.IUnknown)ByVal site As Object) As
Integer

<PreserveSig()_
Function GetSite _
(ByRef guid As Guid, ByRef ppvSite As IntPtr) As Integer
End Interface
End Class
------------------------------------------------------------------------------
------------ Error
---------------------------------------------------------
BHO.vb(6): '>' expected.
BHO.vb(10): Type 'PreserveSig' is not defined.
BHO.vb(12): Type 'MarshalAs' is not defined.
BHO.vb(14): Type 'PreserveSig' is not defined.
------------------------------------------------------------------------------

I don't know what the next step.

Thanks for your help again.
Feb 14 '07 #8
Sorry for such silly question,
I forget to import System.Runtime.InteropServices.

I search for sites and still dunno what is the meaning of PreserveSig
and MarshalAs.
Does anyone can explain whats that.

Thank you so much.

Feb 14 '07 #9
On 2007-02-14, Cylix <cy*******@gmail.comwrote:
Sorry for such silly question,
I forget to import System.Runtime.InteropServices.

I search for sites and still dunno what is the meaning of PreserveSig
and MarshalAs.
Does anyone can explain whats that.

Thank you so much.
Sure...

MarshalAs is a hint to the marshaling engine about what type is expected. For
example, it is a mapping so to speak between the native .net type and the
native data type of the called assembly.

PreserveSig tells the runtime to ignore normal HRESULT, retval behavior. The
real return value of a COM function is an HRESULT. All other return values
are returned via a [out, retval] parameter... So, a function that looked like
this in COM:

HRESULT DoCoolStuff ([in] int i, [out, retval] int* j);

would translate into:

Function DoCoolStuff (ByVal i As Integer) As Integer

That's well and good - unless your function can return a success value other
then S_OK.... See, there are times when you can have COM functions that can
return other values that still represent success. So, you want to capture
that (and sometimes it is important)... But, the problem is if the function
returns anything other then S_OK the .net runtime will discard the [out,
retval] parameter and throw an exception based of the HRESULT (some HRESULTS
map to native .NET exceptions - some don't, in that case you get a
COMException). PreserveSig prevents this behavior. By adding PreserveSig you
can then get the actual HRESULT value for inspection... So, your above
function is now something like:

Function DoCoolStuff (ByVal i As Integer, <OutByRef j) As Integer

HTH,

--
Tom Shelton
Feb 14 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Greg Hurlman | last post by:
I've got what I'm sure is a very simple problem. In an ASP page, I am trying to write out 4 fields from a recordset in succession: Response.Write rs("LastName") Response.Write rs("Suffix")...
1
by: techy techno | last post by:
Hii Just wanted to know how can I decorate my texboxes and Listmenu which is called from a JS file using the following code below: document.write("<SELECT NAME='cur2' ONCHANGE='cconv1();'>");...
2
by: Brett Baisley | last post by:
Hello I have a block of html code that I want to run by calling a javascript function to print it. Its basically a table with menu items in it that is the same for many pages, and instead of...
0
by: hari krishna | last post by:
hi all, My requirement is to generate xl reports throu Asp.Net without installing xl on web server computer. i am using Response object and wrtifile method as below. i dont know whether it is...
14
by: Hugh Welford | last post by:
Hi - trying to display a memo field using response.write but it truncates it. Is there a size issue with response.write? If so how do I get round it and to be able to display the whole memo field ...
8
by: Sowen | last post by:
Hi, all I am wondering how to write bits by using ofstream? I have finished a huffman tree, but how can I write the bits to the file in order to gain compression? for example, 'A' returns a...
13
by: Stumped and Confused | last post by:
Hello, I really, really, need some help here - I've spent hours trying to find a solution. In a nutshell, I'm trying to have a user input a value in form's textfield. The value should then be...
46
by: Ian Boyd | last post by:
IIS5, on a Windows 2000 Server machine. Debeg.WriteLine "Hello, world!" How can i view it?
9
by: sonnystarks | last post by:
I am taking a course in writing javascript and it (and all the books I have been reading) tell me that if I will use the document.write syntax, I will be able to "place text on the page." None...
0
by: musosmiffy | last post by:
Hi, I have been trying to get the following working for days - I wonder if anyone could help me? I am trying to list a set of database entries as a newspaper column. I am using classic ASP (not...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.