How to open and perform write on a file in a DLL?

75 views Asked by At

I am developing an internet-explorer plug-in (Browser Helper Object-BHO) in C++. In that, when the event BeforeNavigate2 is fired I want to save the URL to a file.

Therefore, to open the file I wrote the usual code:

FILE* fp;
fp = fopen("E:\\visurl.txt", "a");

if (fp == NULL){
    MessageBox(NULL, "fopen failed!", _T("BHO!!!"), MB_OK | MB_ICONINFORMATION);
}
else{
    MessageBox(NULL, "fopen succeeded!", _T("BHO!!!"), MB_OK | MB_ICONINFORMATION);

    //here I would append the url in the file poined by *fp

    fclose(fp);
}

And every-time it displays the "fopen failed" message.

What could be the problem? Please help. I need it badly. Thank you.

1

There are 1 answers

0
CodeWhore On

Just to point others that may stumble upon this where modifying the way the user has configured his browser by changing the enhanced protected mode setting on the browser if you need to write to a file within IE while it is running in enhanced protected mode one handy location that already exists that has low integrity label associated with it is the users//AppData/LocalLow folder.