Hi Emre, thanks for linking your solution. Here is what I've done so far, with advice and code snippets from both of you.

It currently isnt working 100%, but here is the major parts of the code that I believe help a lot, I think it completely got rid of the 3d Hardware Reset failure crash when waking up from a screensaver:

Code
#include <windows.h>  //----------include windows.h

...

function main()
{

var render_chain_destroy=0;
var render_chain_state=0;

while(1) ///--------------------put this in your main loop
{

BOOL bSaver;  //--------------------------------creates a BOOL flag that will be changed by the windows.h function SystemParametersInfo
SystemParametersInfo(114,0,&bSaver,0);  //---------114 is a specific parameter that tells gamestudio whether or not a screensaver is running

...


        //---------If bSaver is 1/true then it means the windows screensaver is running:

	if((bSaver)||(window_focus==0))  //-----------bSaver is a flag set by SystemParametersInfo above. I put window_focus in here as well 
	{

   render_chain_destroy=1;  //-------get ready to destroy the render chain

        }

       else
      {

      render_chain_destroy=0;  //-------if the screen saver isnt running, dont destroy the render chain

      }



if(render_chain_destroy==1)  //-----we are ready to destroy the render chain because the screensaver is on
{

if(render_chain_state==0)
{

destroy_render_chain();  //-------put your render chain destruction here (remove stages, remove bmaps, purge bmaps
render_chain_state=1;  //-----destroy the chain once
}


}


if(render_chain_destroy==0)  //-------if the system doesnt have a screensaver running
{

if(render_chain_state==1) //------and we recently destroyed the render chain because we destroyed it when a screensaver came on before
{
recreate_render_chain(); //--------recreate your render chain here
wait(-2); //------------I waited 2 seconds here, not sure if this helps or not
render_chain_state=0;  //-------we reset this var to 0, which is only set to 1 when a screensaver is on.

}


}


There some caveats to the above screensaver code. It only consistently works if gamestudio is running in a window. Obviously, if gamestudio is full screen, the screensaver will never trigger.

But lets work on the next hurdle. Locking your computer.

...
if (DeskHwnd != 0)
{
DesktopResult = SwitchDesktop(DeskHwnd);
}


if((DesktopResult==0)||(key_o))
{
...

With Emre's code, I can get gamestudio to recognize when the computer is locked! I destroy the render chain and remove the stages the moment gamestudio detects a lock.

However, when you log back in to a running windowed gamestudio exe, the game gave me a "cant create texture unnamed", but it didnt crash the game. When you select OK, the game seems to run ok in windowed mode after.

If you run the game in fullscreen, then lock, destroy the render chain in gamestudio, then log back in, the game looks like its frozen, however if you press alt+enter, the game seems to unfreeze and start working again.

Emre, have you tried to see if your game works when you run fullscreen, then lock, then log back into the desktop to see what a running gamestudio does?

Thank you two for your help so far.