creating context, opengl drawing(Visual Studio 6)

Hi,
I have two applications. First one (let’s say A) draws opengl objects on the window of second application(let’s say B). Thread of A creates opengl context using the handle to device context of window of B. when closing A, I am calling wglMakeCurrent(NULL,NULL). Then, ReleaseDC and wglDeleteContext are called in order. B is still running. Then, I am running A again, which makes my computer crash. But, this code runs properly in some of other computers. To run my applications properly, when I stop running A, I have to stop B too. Then I have to run both of them again. What can be the problem? My computer crashes wglMakeCurrent call in the second run of A(while B is runnnig).

when closing A, I am calling wglMakeCurrent(NULL,NULL). Then, ReleaseDC and wglDeleteContext are called in order.

– try wglDeleteContext before ReleaseDC?

I tried, but it didn’t work.

Actually, after wglMakeCurrent(NULL,NULL) is called, GetLastError() returns 6 (ERROR_INVALID_HANDLE).Also, after wglDeleteContext is called, GetLastError() returns 170 (ERROR_BUSY).(Visual Studio 6)

Can the problem occur because of these errors?