争怎路由网:是一个主要分享无线路由器安装设置经验的网站,汇总WiFi常见问题的解决方法。

WINDOWS9x 的后台进程

时间:2024/7/15作者:未知来源:争怎路由网人气:

KEY_SET_VALUE,
          &hKey ) != ERROR_SUCCESS )
   {
       if( RegCreateKey( HKEY_LOCAL_MACHINE,
          TEXT( "SOFTWARE\\Microsoft\\
          Windows\\CurrentVersion\\RunServices"),
          &hKey ) != ERROR_SUCCESS )
       {
           //DebugOut( "RegCreateKey() error!");
           return FALSE;
       }
   }

   dwValueType   = REG_SZ;
   dwStrCb     = 128;

   // Take value
   if( RegQueryValueEx(hKey,
        SERVICE_NAME,
        0,
        &dwValueType,
        (LPBYTE)lpszStr,
        &dwStrCb ) == ERROR_SUCCESS )
   
   {
       // Find this key value
       if( _tcscmp( lpszStr, lpszName )==0 )
       {
           // Remove the service
           if( dwType == RSP_UNREGISTER_SERVICE )
           {
            if(RegDeleteValue( hKey, SERVICE_NAME )
             == ERROR_SUCCESS )
               {
                   RegCloseKey ( hKey );
                   return TRUE;
               }
               RegCloseKey( hKey );
               return FALSE;
           }
           // Already exist service
           if( dwType == RSP_SIMPLE_SERVICE )
           {
               //DebugOut("Already registed!");
               RegCloseKey( hKey );
               return TRUE;
           }
       }
       // Not find it
   } // No this value

   // Unregiste return
   if( dwType == RSP_UNREGISTER_SERVICE )
   {
       RegCloseKey( hKey );
       return TRUE;
   }

   // No this value then create it
   if( dwType == RSP_SIMPLE_SERVICE )
   {
       dwStrCb = 128;

       // Set value
       if( RegSetValueEx(hKey,
                   SERVICE_NAME,
                   0,
                   REG_SZ,
                   (CONST BYTE *)lpszName,
                   dwStrCb ) != ERROR_SUCCESS )
       {
           //DebugOut("RegSetValueEx() error!");
           RegCloseKey( hKey );

           return FALSE;
       }
       RegCloseKey( hKey );
       return TRUE;
   }

   // Unknow type
   RegCloseKey( hKey );
   return FALSE;
}
---- 主 程 序:

// WinMain function is the entry of the this program
int APIENTRY WinMain(HINSTANCE hInstance,
          HINSTANCE hPrevInstance,
          LPSTR   lpCmdLine,
          int    nCmdShow)
{
   if( W95ServiceRegister( RSP_SIMPLE_SERVICE ) )
   {
       W95StartService( RSP_SIMPLE_SERVICE );
   }

   MessageBox(NULL, "Sample service", "SERVICE", MB_OK );
   UNREFERENCED_PARAMETER( hInstance );
   UNREFERENCED_PARAMETER( lpCmdLine );
   UNREFERENCED_PARAMETER( nCmdShow );
   UNREFERENCED_PARAMETER( hPrevInstance );
   return 0;
}


----运行这个程序,等到MessageBox弹出后,从WINDOWS中退出到LOGON状态,你会看见MessageBox一直保持打开状态直至受到响应或系统关机.所以要做WINDOWS95下系统级的后台进程,并不一定非要去编写容易引起系统混乱的VXD程序,在硬件部分允许的情况下,我认为本文介绍的方法更加方便有效.

关键词:WINDOWS9x 的后台进程




Copyright © 2012-2018 争怎路由网(http://www.zhengzen.com) .All Rights Reserved 网站地图 友情链接

免责声明:本站资源均来自互联网收集 如有侵犯到您利益的地方请及时联系管理删除,敬请见谅!

QQ:1006262270   邮箱:kfyvi376850063@126.com   手机版