Your question is too broad for a technical forum; we deal here with specific problems. For general "how to" questions you need to do the research and find the samples and articles that will help to build your project.
I want to develop a DLL that has a web browser embedded in it. ...then load this
DLL into a web browser like IE, Chrome or Firefox.
So you have a web browser (doesn't matter whether you create it or not) and then run it in a web browser.
The question is similar to asking if one would want to run Chrome inside of Firefox.
Don Guy wrote:
Is this possible to do?
It is possible to create a web browser in a dll. To create a functioning browser then one would simply use the dll in the exe and call probably one method.
That said a web browser is a user tool and a client side tool. I doubt there is any need to have a browser that one can embed and moreover it would likely irritate users because a non-trivial number of them are really attached to the browser they use.
Standard browsers can run executable content if the users allow that. The executable content can be anything, so it could certainly start a browser.
But excluding attempts to circumvent security and attempt to hack information from users I can't see any point to this.
If you want something inside the function protected from parallel/recursive calls, you can do that by placing a criitical section and a class member variable inside it. If don't want the function to be called at all, you could make it private and add a public function as the only one that calls it. It could look something like that:
EnterCriticalSection(); // keep other treads outtry
if (!alreadyRunning) // static private member variable to prevent recursive calls
alreadyRunning = true;
alreadyRunning = false;
alreadyRunning = false; // important to do that before leaving the critical section
LeaveCriticalSection(); // prevent a dead lockthrow; // let the caller decide what to do with the initial exception
So privateFunction() will only be called once at a time no matter from which thread (provided you don't add another member function that calls it or introduce any friend classes).
The good thing about pessimism is, that you are always either right or pleasently surprised.
Not bad but in C++ you should use RAII for this, use the destructor of an auto (stack) object as your finally block.
// do work here, cs will be automatically released when leaving the function
// the cs2 criticalsection will be left automatically at the end of this scope
// do work
For one, this article promotes 80's #define's as if they're still a valuable solution (hint: a global const variable can do the same and is always the better option).
Also the later suggestion is not only obvious (use member variables, duh!), but actually needlessly complicates things: you can name structs just like classes without typedef's, and if you really need a global structure for these things, use templates! How can code with #define's and typedef's be called "Optimized for C++11", when it looks more like C72?
Now I am wondering: Is the article that bad? Is he mentioning valid points ( I got him with the "use templates", but I am still not sure whether I can trust him or not - After all, his profile says "Web developer").
Since I want to provide quality articles to the community I'd also want a feedback on what I could improve with the article to make it more valuable and up-to-date.
Thanks for any help
You know the world is going crazy when the best rapper is a white guy, the best golfer is a black guy, the tallest guy in the NBA is Chinese, the Swiss hold the America's Cup, France is accusing the U.S. of arrogance, Germany doesn't want to go to war, and the three most powerful men in America are named "Bush", "Dick", and "Colon."
I've just taken a quick look at your article but I agree with the guy. To me it seems that you are a C programmer who is quite new in C++. Defines should be avoided whenever possible. In a lot of cases defines can be replaced with template/inline functions. In some other cases long macros can be replaced to a combination of a short macro + template/inline functions/classes. Macros don't respect name spaces and they arent type safe. Still, some small stupid problems can be solved practically only with macros (for example automatically logging out filename/linenumber/functionname can be done only with a logger macro). But even when you are using a macro its better to keep the body of the macro short by immediately calling a function or intantiating/using a class. Using typedef on structs in C++ is awkward and using header guards is also deprecated in my opinion, in a large project you got a very strange error message with a duplicate (for example copy-pasted) header guard and today all major compilers support "#pragma once".
Last Visit: 31-Dec-99 18:00 Last Update: 25-Jun-18 0:47