|
Why not do the processing in a subthread created with the THREAD_PRIORITY_IDLE thread priority?
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
hi,
but I have my one idle conditions. How can I check that conditions like
1) whether the CPU utilization is less than 10%
2) whethter there is load on HDD
regards,
ajay
|
|
|
|
|
how do i export classes using regular dll?
because i donot want to use an extension DLL to export classes.
regards
Shailesh
|
|
|
|
|
how do i export classes using regular dll?
because i donot want to use an extension DLL to export classes.
regards
Shailesh
|
|
|
|
|
Shailesh Halankar wrote: how do i export classes using regular dll?
#define DllExport <code>__declspec( dllexport )</code>
class <code>DllExport</code> C
{
int i;
virtual int func( void )
{ return 1; }
};
Nibu thomas
A Developer
Programming tips[^] My site[^]
|
|
|
|
|
Thanks for the INFO
how will the client import the exported class i.e wher should the __declspec( dllimport ) statement be used?
|
|
|
|
|
Shailesh Halankar wrote: wher should the __declspec( dllimport ) statement be used?
Replace dllexport by dllimport . Rest is the same.
Nibu thomas
A Developer
Programming tips[^] My site[^]
|
|
|
|
|
Shailesh Halankar wrote: how do i export classes using regular dll?
because i donot want to use an extension DLL to export classes.
In continuation with Nibu, you have to include the lib and header file in your project!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
|
Hi All,
I want to write the contents of the edit box to file i have used this code but its not working can u tell me the cause..
i want to remove the old contetns and add the contetns of the edit box.
str holds the file name.
CStdioFile file(str, CFile::modeWrite);
file.Open(str);
char *pBuffer = new char[dwSize + 1];
m_FCONT.GetWindowText(*pBuffer);
UINT uWrite = file.Write(pBuffer, dwSize);
delete [] pBuffer;
Regards,
Vinay Charan.
|
|
|
|
|
you can use (CArchive /CFile)for your work
whitesky
|
|
|
|
|
Hi whitesky,
I have used CFile but i am nt getting how to save in the file can u plz c the code.
Regards,
Vinay Charan.
|
|
|
|
|
See one example Here[^] maybe it is some helpful to you
whitesky
|
|
|
|
|
and one simple example
<br />
CFile m_File("c:\\text2.txt",CFile::modeCreate|CFile::modeWrite);<br />
<br />
TCHAR buf[120];<br />
m_Edit1.GetWindowText(buf,sizeof(buf));<br />
m_File.Write(buf, lstrlen(buf));<br />
m_File.Close();<br />
whitesky
|
|
|
|
|
In Continuation with WhiteSky,
better option will CStdioFile, which deal will Text based File
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
VinayCool wrote: ...but its not working
What is not working? Be specific.
VinayCool wrote: file.Open(str);
It is not necessary to call the Open() method. The constructor has already done this.
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
try this;
char buff[] = "Test Data";
CStdioFile file("c:\\Test.txt", CFile::modeCreate | CFile::modeWrite);
file.WriteString( buff );
file.Close();
i think you forget to set file creation open flag.
|
|
|
|
|
Hi!
Please, can you give me a link to find out the way to define/declare a function in C++, export it as a 'standard' dll, and then use it in a basic program.
I need to do this only to understand the procedure,
so the function can be very very simple; something like this:
extern "C" int Foo(int param){<br />
return param+3;<br />
}
Cheers,
Russell
|
|
|
|
|
Lets see if this can help you
Just giving a try on this.
The module definition file lists the functions exported by a dynamic link library. All you have got to do is to list the names of the functions you are exporting to the EXPORTS section of the file
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
I think that I'm near to the solution:
I'm trying to follow this example(http://www.it-lang-vb.net/Documentazione/Articoli/DllxVb.htm[^])(sorry but the comments are in italian lenguage), but I'm using VS.NET 2003 and this, probally, is creating compilers version problems.
Do you know if this code lines are not compatible with my version of VS?
Cheers,
Russell
|
|
|
|
|
|
Hello. I'm currently working on a program which uses DHTML for user interface, and some elements of the interface need to be called on network events (so without the user clicking on anything). All samples on CodeProject use user clicks, and actually the other method fails! Let me explain.
I've actually created a new project to show the problem. You'll find it on http://temp.alishomepage.com/.RMI/JavaScript.zip. That project has been created to show the JavaScript call problem with the CHtmlView class: failure in the execScript method when called from a thread.
The project has been generated by Visual C++ 6 as a standard MFC project with CHtmlView as the view class. All changes in files are marked with the comment "JavaScript problem sample", and involve the JavaScriptView.h and .cpp files.
In JavaScriptView.h, there's an override of the OnDocumentComplete method.
In JavaScriptView.cpp, we add the two header files (atlbase.h and mshtml.h) as well as the the following function (headers are needed by the function):
<br />
DWORD WINAPI CallJScriptLater( LPVOID lpParam )<br />
{<br />
CComQIPtr<IHTMLDocument2> pHtmlDoc( ((CJavaScriptView*) lpParam)->GetHtmlDocument() );<br />
<br />
CComPtr<IHTMLWindow2> pWnd;<br />
pHtmlDoc->get_parentWindow( &pWnd );<br />
<br />
CComBSTR bstrMember(CString("alert('boo')"));<br />
<br />
CComBSTR vtlanguage(CString("javascript"));<br />
VARIANT vresult;<br />
<br />
pWnd->execScript(bstrMember,vtlanguage,&vresult);<br />
<br />
return 0;<br />
}<br />
And the added function is called on document complete:
<br />
void CJavaScriptView::OnDocumentComplete( LPCTSTR lpzsURL )<br />
{<br />
CHtmlView::OnDocumentComplete( lpzsURL );<br />
<br />
#if 1<br />
CallJScriptLater( this );<br />
#else<br />
CreateThread( NULL, 0, CallJScriptLater, this, 0, NULL);<br />
#endif<br />
<br />
}<br />
Finally, OnInitialUpdate has been changed:
<br />
void CJavaScriptView::OnInitialUpdate()<br />
{<br />
CHtmlView::OnInitialUpdate();<br />
<br />
Navigate2(_T("about:blank"),NULL,NULL);<br />
}<br />
As a result, the program:
- On initializatio complete, loads about:blank
- When loading complete, calls executes the JavaScript: alert('boo')
That call may be in two ways:
- Directly (if the OnDocumentComplete has #if 1)
- Via a thread (if the OnDocumentComplete has #if 0)
PROBLEM: The direct call (JavaScript_directCall.exe) succeeds whereas the thread call (JavaScript_threadCall.exe) fails.
If anyone has a solution please let me know.
Thank you
S. Ali Tokmen
http://ali.tokmen.com
|
|
|
|
|
Now that's really odd...
Have you tried creating the thread with AfxBeginThread?
I'm asking because Microsoft claims the other methods aren't MFC-safe.
|
|
|
|
|
Hello, HAND
Thank you for your reply. Using AfxBeginThread instead of the CreateThread function doesn't unfortunately solve the problem... If you want to see the exact project, please look at http://temp.alishomepage.com/.RMI/JavaScript.zip
I think the issue is due to the fact that the one of those objects there (CHtmlView, presumably) is created in mono-thread mode and does not accept script calls from other threads. Even worse, if the host has Internet Explorer 5 installed (default Windows 2000 SP4 configuration) the script call makes the program crash! See http://support.microsoft.com/kb/318426
I'm starting to have a solution idea, thought: creating the entire HTML output using the IHtmlDocument2::write method and then calling JavaScript from there. It seems to work, but has a majot disadvantage: every JavaScript call adds at least one line to the source code!
Another idea would be JavaScript to "ping" the C++ at regular intervals and C++ to catch that and respond using a JavaScript call.
Thank you for your reply.
S. Ali Tokmen
http://ali.tokmen.com
|
|
|
|
|
Hello, everyone
First of all, I would like to thank everyone who has helped identifying the cause of this issue and, of course, proposed ideas of solution.
The problem seems to be that the scripting object of the IHtmlDocument interface (in its current -Windows XP SP2- implementation) has some protection against access to its inner elements from external threads. As a result, calls from other threads to function that get the content of an HTML document or call scripts on it is prohibited.
There's a solution, thought: create a class which would try to call a script using standard methods and on failure queue the request. That class should of course also have a method to execute all queued calls (you can use CList for that queue).
Then, you have to find a method to get in the same thread as the CHtmlDocument interface... Which is not that hard: first, put the setInterval("window.navigate('refreshjs:')",1000) line in your HTML document as a JavaScript. This will, every second, try to navigate to refreshjs:
Second, you have to modify the OnBeforeNavigate method of CHtmlView to make it call the queue execution method if a navigation to refreshjs: is requested (note that you can also stop navigation at that point -refreshjs: is not a valid protocol anyway!)
Using this method, JavaScript calls that fail will be re-executed at most one second later... And shall now not fail, except if you've really called a function that doesn't exist!
S. Ali Tokmen
http://ali.tokmen.com
|
|
|
|