|
Hi!
I had download the source code of mass storage device driver for windows98 from Microsoft websit.And builded it with 98ddk on windows98 system,and then
installed it on win98 system. It can work correctly all the time.
If I suddenly remove the device from pc when copying file from pc to device or from device to pc on win98 system,the blue screen occur,and i have to restart my system.
But if do the same on win2000 or winxp there is no blue screen.
Now i wanna modify the driver source code to avoid the blue screen when suddently remove the device while it is exchanging data with pc on win98 system.
My question is:
1,If my hope has the possibility to come true?
2,If has,then which part of source code of this drive should i have to modify,and what couses the blue screen?
I know that in the source code it just abort all the pipes when device remove sudently but nothing else.
Thanks!
momer
All the blesses we are enjoy are the fruit of labor,toil,study and selt-denail.
|
|
|
|
|
Hi,
Is there any upgradation tool for migrating VC++ 6.0 code to VC++ 2005 code. This project in VC++ 6.0 has ATL and COM components.
Are there complete tutorial for this upgradation.
Is there any tool that upgrades atleast partially?
Any help in this regard is appreciated.
Sugan
Chennai
-- modified at 6:27 Friday 17th February, 2006
|
|
|
|
|
You can try opening it with Visual 2005 studio it will ask for converting teh code from VC++ 6.0 to vc++ 7.0
Cheers
|
|
|
|
|
You can try opening it with Visual 2005 studio it will ask for converting the code from VC++ 6.0 to vc++ 7.0
Cheers
|
|
|
|
|
|
Well thanx for the info.
Hey can you give me a link where i can fnd the diffrence between Vc++.net 2002 and Vc++.net 2005
Cheers
|
|
|
|
|
Hello,
I usually work with microcontrollers in a C/C++ environment, but i need to write a programm to download software in the microcontrollers (through RS232). I want to do this in Visual C++. I allready have written software that downloads the software correctly, but while downloading, my programm hangs. I would like to use multithreading to prevent this.
Whereever I look for help, it appears to be too complicated for a beginner like me. I just want my programm to have 2 threads: 1 for the serial communication and 1 for the GUI.
|
|
|
|
|
u can use CreateThread() function for this. The function creates a new thread.
eg:
CreateThread( 0, 0,(LPTHREAD_START_ROUTINE)ThreadProc, 0, 0, 0 );
When the above function is called, anew thread will be created and it will call the function ThreadProc
The function ThreadProc must be define as
DWORD WINAPI ThreadProc(
LPVOID lpParameter
)
{
// begining of new thread
}
nav
|
|
|
|
|
If you plan on using any CRT functions (C/C++ runtime) like malloc etc, then rather than using CreateThread, you should use _beginthreadex. You need to make sure that you're building a multithreaded app and using the right versions of the runtime libraries. A simple check is
#if !defined(_MT)
#error "Not building correctly"
#endif
since selecting multithreaded runtine libraries will defined _MT as a preprocessor symbol. Of the arguments to _beginthreadex, you are usually best passing 'security' as NULL, stack_size as zero.
If you've never used multiple threads before, then you're in for a treat, since it will involve an element of synchronisation.
Steve S
Developer for hire
|
|
|
|
|
bolleperdu wrote: Whereever I look for help, it appears to be too complicated for a beginner like me. I just want my programm to have 2 threads: 1 for the serial communication and 1 for the GUI.
http://www.flounder.com/workerthreads.htm[^]
"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
|
|
|
|
|
Thanks for the response! The problem is that I want to show how much of the serial data is allready transmitted.
My programming skills are extremely basic: I create my forms using the windows form designer , I don't create them from my own code.
Would using the class "using namespace System::Threading;" for my threading be the easiest way?
<br />
try<br />
{<br />
StreamReader^ sr = gcnew StreamReader(teversturen);
{<br />
String^ line;<br />
int lengte = (unsigned int)sr->BaseStream->Length; <br />
int percent; <br />
while (!(sr->EndOfStream::get()))<br />
{<br />
percent = (((unsigned int)sr->BaseStream->Position / lengte) * 100);
toolPCT->Text = percent.ToString() + "%";
<br />
line = sr->ReadLine();
sp->WriteLine(line);
Form1::Update();
}<br />
}<br />
sr->Close();<br />
<br />
}<br />
catch (Exception^ e)<br />
{<br />
richTextBox1->Text += "The file not be read:\n";<br />
richTextBox1->Text += e->Message + "\n";<br />
sp->Close();<br />
}
Above you can find my code. I would like the percentage to be shown at least with an accuracy of 10 pct, or an update every 2 - 5 seconds. If this could be achieved without multithreading, that would please me even more:p The serial communication takes lots of time and the users would like to be able to cancel, see the status, ...
|
|
|
|
|
Hi, All.
I have problem in my app. In my app, i have aciton [COPY File/Folder], switch Window Explore. When you right click > Paste, i want to active my app to run some function. after that, Do Paste.
Now, i will use hook to do that but i don't know, when window explorer paste, it call what API function.
Please, help me to to solve this problem.
Thanks.
|
|
|
|
|
Normaly pasting is accomplished through the clipboard; that is you query the clipboard for the current items available for pasting. You can search for pasting in the MSDN, but you might have more success looking at OLE information on things like "drag and drop". Unless you need to know specificaly that the item being pasted is coming from Windows Explorer, then you should not need a hook. Of course if the function doing the pasting is in a control that you are using in you application, then you would need to hook that control.
INTP
Every thing is relative...
|
|
|
|
|
thank you very much. i try and will send you result.
|
|
|
|
|
i use delayed rendering Clipboard
BeginWaitCursor();
OpenClipboard()
::EmptyClipboard();
::SetClipboardData (CF_HDROP, NULL);
::CloseClipboard();
EndWaitCursor();
and i process message
use with WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
switch(message)
{
case WM_RENDERFORMAT:
function1();
case WM_RENDERALLFORMATS:
function2();
case WM_DESTROYCLIPBOARD:
function3();
when use right click, my app immediately active and call function to function1->2->3. I think is not true for my problem.
probable, i don't understand your solution.
Can you help me again.
Best regards and many thanks.
|
|
|
|
|
I did not really give a solution, I just suggested an area to search for the information. I beleive there are articles at CP (or CodeGuru) on the subject.
I thought you where pasting to your app from the clipboard. What you are showing me is a possible method for adding something to the clipboard. Also your swith() has no break statements in it, so if the case is WM_RENDERFORMAT, then all the functions will be called (function1(), function2(), and function3()).
Well it's 3:43 AM here, so I have to say good night.
INTP
Every thing is relative...
|
|
|
|
|
I want to desgin a MDI application window which look and feel like Microsoft Visual Studio 2005 with the property box etc. The client area should be like MS Access Report Designer with header,footer,rulers sections. How can design such a window
|
|
|
|
|
Hire a team of programmers to help you. Otherwise look at the frame works available, that may provide some of the features you are looking for. There may be anouther way, if the user of the software has MS Access Report Designer installed on the same system, but I do not know. You never know, somebody may have designed a drop in that looks like what you are looking for.
INTP
Every thing is relative...
|
|
|
|
|
Hello
I am using CWinThread for threading in MFC. I want to terminate a thread from another function not in the thread function itself. Can i do that?
Thank You.
We Believe in Excellence
-- modified at 1:10 Friday 17th February, 2006
|
|
|
|
|
Briefly: TerminateThread()
Details: Avoid using this function:
a) Proper application cleanup does not occur: C++ object destructors aren't called, data isn't flushed to disk, and so on.
b) If TerminateThread is used, the system does not destroy the thread's stack until the process that owned the thread terminates.
c) DLLs usually receive notifications when a thread is terminating. If a thread is forcibly killed with TerminateThread, however, the DLLs do not receive this notification, which can prevent proper cleanup.
If you link your application to the C++ standard library, consider using _beginthreadex(...) and _endthreadex(...).
|
|
|
|
|
Aqueel wrote: I want to terminate a thread from another function
if the other function is the part of another thread you can terminate the first thread using a signaling mechanism.
"Every morning I go through Forbes list of 40 richest people in the world. If my name is not in there, I go to work..!!!"
|
|
|
|
|
Your asking for trouble even thinking of calling TerminateThread. Here's an example program which shows the kind of thing that can go wrong:
------------------------------------------
#include <windows.h>
CRITICAL_SECTION g_cs;
void ShowMessageBox()
{
EnterCriticalSection(&g_cs);
MessageBox(NULL, "Hello", "ShowMessageBox", MB_OK);
LeaveCriticalSection(&g_cs);
}
DWORD WINAPI ThreadProc(LPVOID lpParameter)
{
ShowMessageBox();
return 0;
}
int main(int argc, char* argv[])
{
InitializeCriticalSection(&g_cs);
// Start thread.
DWORD ThreadID;
HANDLE hThread = CreateThread(NULL, 0, &ThreadProc, 0, 0, &ThreadID);
// Wait for one second then kill the thread.
// It still holds the CRITICAL_SECTION!!!
Sleep(1000);
TerminateThread(hThread, 0);
// We've killed the "ShowMessageBox" API, permanently, calling it now
// causes this thread to dead lock!
ShowMessageBox();
DeleteCriticalSection(&g_cs);
return 0;
}
------------------------------------------
In this program calling TerminateThread permanently breaks ShowMessageBox because we killed the thread when it still held a lock. This is the worst kind of bug as it's very hard to reproduce as it's sensitive to timing. If you're calling Win32 functions many of them will briefly hold locks, if you terminate a thread while it is holding one you're screwed.
Moral: Don't call TerminateThread. There are exceptions but very few.
The only real safe way to terminate a thread from another thread is to ask it nicely. This generally involves signaling an event and then waiting on the thread handle.
Steve
|
|
|
|
|
Absolutely, there are plenty of trouble with this function that is why I suggested avoiding it. It seems to me though that Aqueel wanted something like this asking
[quote]to terminate a thread from another function not in the thread function itself[/quote].
So, he does not seem to want to terminate the thread from "inside" for whatever reason.
|
|
|
|
|
I understand that you suggested he avoid it. I just wanted to clarify the dangers as in general if you use TerminateThread then it is a case of the cure being worse then the disease.
Steve
|
|
|
|
|
Can he want to use it for debug purposes? Say, when his other thread freezes, does not exit properly, stops processing messages, then it may be OK to use it to terminate the other thread and print a status info?
BTW, thanks for the code. For my notes I should keep your example as another reason to avoid it.
|
|
|
|