Click here to Skip to main content
15,914,111 members
Home / Discussions / C#
   

C#

 
GeneralRe: open file for writing text(not bytes) and share access Pin
Giorgi Dalakishvili17-Nov-07 8:20
mentorGiorgi Dalakishvili17-Nov-07 8:20 
GeneralRe: open file for writing text(not bytes) and share access Pin
Giorgi Dalakishvili17-Nov-07 9:48
mentorGiorgi Dalakishvili17-Nov-07 9:48 
GeneralRe: open file for writing text(not bytes) and share access Pin
gizmokaka17-Nov-07 8:40
gizmokaka17-Nov-07 8:40 
GeneralRe: open file for writing text(not bytes) and share access Pin
Luc Pattyn18-Nov-07 1:34
sitebuilderLuc Pattyn18-Nov-07 1:34 
GeneralRe: open file for writing text(not bytes) and share access Pin
Giorgi Dalakishvili17-Nov-07 9:56
mentorGiorgi Dalakishvili17-Nov-07 9:56 
GeneralRe: open file for writing text(not bytes) and share access Pin
gizmokaka17-Nov-07 10:20
gizmokaka17-Nov-07 10:20 
GeneralRe: open file for writing text(not bytes) and share access Pin
gizmokaka17-Nov-07 12:31
gizmokaka17-Nov-07 12:31 
QuestionProblem Getting C# BHO To Work Pin
Khoramdin17-Nov-07 6:10
Khoramdin17-Nov-07 6:10 
Hello everyone,

I have what should be a relatively simple C# .NET 2.0 IE BHO that I am really struggling with. The goal of the BHO is to provide a hook when the users opens a web-page the HelloWorld! message appears.

I am using Visual Studio 2005 Profesional Edition and do the following:

1- Build Solution (F6)
2- Fire an Internet Explorer (IE)
3- (From Visual Studio) Debug -> Attach to Process...
4- Select the Internet Explorer (IE) that was started in 1.
5- Attach

At this point I can see in the StatusBar loading message for verious files.

If I am not mistaken at this point my simple BHO should be attached to the Internet Explorer (IE). when I move from the webpage to other pages I expect for the HelloWorld MessageBox to pop-up once the website is loaded. But sadly, nothing happens!

The codes are:

IObjectWithSite.cs

using System;
using System.Runtime.InteropServices;

namespace WebWatcher
{
    [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);
    }
}


BHO.cs
using System;
using System.Collections.Generic;
using System.Text;
using SHDocVw;
using mshtml;
using System.IO;
using Microsoft.Win32;
using System.Runtime.InteropServices;

namespace WebWatcher
{
    [
    ComVisible(true),
    Guid("8a194578-81ea-4850-9911-13ba2d71efbd"),
    ClassInterface(ClassInterfaceType.None)
    ]
    public class BHO : IObjectWithSite
    {
        private SHDocVw.WebBrowser webBrowser;
       
        public void OnDocumentComplete(object pDisp, ref object URL)
        {
            System.Windows.Forms.MessageBox.Show("HelloWorld!");
        }

        #region WebWatcher Internal Functions
        public int SetSite(object site)
        {

            if (site != null)
            {
                webBrowser = (SHDocVw.WebBrowser)site;
                webBrowser.DocumentComplete += new DWebBrowserEvents2_DocumentCompleteEventHandler(this.OnDocumentComplete);
            }
            else
            {
                webBrowser.DocumentComplete -= new DWebBrowserEvents2_DocumentCompleteEventHandler(this.OnDocumentComplete);
                webBrowser = null;
            }

            return 0;

        }

        public int GetSite(ref Guid guid, out IntPtr ppvSite)
        {
            IntPtr punk = Marshal.GetIUnknownForObject(webBrowser);
            int hr = Marshal.QueryInterface(punk, ref guid, out ppvSite);
            Marshal.Release(punk);

            return hr;
        }
        #endregion
    }
}


How can I see what files are been loaded when I attach the codes to the Internet Explorer? Is there any particular setting that I should set the Visual Studio to inorder ro be able to get result? Your help is greatly appriciated. Thank you very much and have a great weekend.

Khoramdin



-- modified at 12:51 Saturday 17th November, 2007
AnswerRe: Problem Getting C# BHO To Work Pin
Not Active17-Nov-07 11:35
mentorNot Active17-Nov-07 11:35 
GeneralRe: Problem Getting C# BHO To Work Pin
Khoramdin17-Nov-07 12:34
Khoramdin17-Nov-07 12:34 
GeneralRe: Problem Getting C# BHO To Work Pin
Not Active17-Nov-07 16:32
mentorNot Active17-Nov-07 16:32 
QuestionAdding Url pattern in Internet Explorer Trusted Site Zone programmatically Pin
h@$@n17-Nov-07 4:04
h@$@n17-Nov-07 4:04 
QuestionWhy asking permission??? Pin
Hum Dum17-Nov-07 2:20
Hum Dum17-Nov-07 2:20 
AnswerRe: Why asking permission??? Pin
pmarfleet17-Nov-07 2:31
pmarfleet17-Nov-07 2:31 
QuestionImage in tree view subnodes different from nodes Pin
D i x y17-Nov-07 1:52
D i x y17-Nov-07 1:52 
AnswerRe: Image in tree view subnodes different from nodes Pin
pmarfleet17-Nov-07 2:36
pmarfleet17-Nov-07 2:36 
QuestionImage in Listview control in window application Pin
D i x y17-Nov-07 1:46
D i x y17-Nov-07 1:46 
AnswerRe: Image in Listview control in window application Pin
pmarfleet17-Nov-07 2:41
pmarfleet17-Nov-07 2:41 
Questionprint form Pin
SVb.net17-Nov-07 1:08
SVb.net17-Nov-07 1:08 
AnswerRe: print form Pin
Abhijit Jana17-Nov-07 1:13
professionalAbhijit Jana17-Nov-07 1:13 
GeneralRe: print form Pin
Anthony Mushrow17-Nov-07 2:24
professionalAnthony Mushrow17-Nov-07 2:24 
Questionprint form Pin
SVb.net17-Nov-07 1:07
SVb.net17-Nov-07 1:07 
Questionprint form Pin
SVb.net17-Nov-07 1:05
SVb.net17-Nov-07 1:05 
Questiontype conversions in .net Pin
sk840516-Nov-07 23:46
sk840516-Nov-07 23:46 
AnswerRe: type conversions in .net Pin
Hesham Amin17-Nov-07 0:41
Hesham Amin17-Nov-07 0:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.