⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tmmanins.c

📁 PNX系列设备驱动 PNX系列设备驱动
💻 C
字号:
#include <windows.h>
#include <setupx.h>   
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <io.h>
#include <stdlib.h>
#include <sys\stat.h>

#define constVendorID	"VEN_1131"
#define constDeviceID   "DEV_5400"

void DeleteOldFiles(void);
void RemoveOldDriver(void);
void InstallDriver(void);
    
int PASCAL WinMain(HANDLE hInstance, HANDLE hPrevInstance, 
                    LPSTR lpCmdLine, int nCmdShow)
{       
	if(MessageBox(NULL,"Warning: This program will delete the existing\n" 
		               "TriMedia device and associated drivers.\n"
				  	   "Do you want to continue?\n",
		"tmmanins.exe",MB_ICONQUESTION | MB_YESNO) == IDYES)
	{
		DeleteOldFiles();
		RemoveOldDriver();
		InstallDriver();
		return 0;
	}
	else
		return 1;
}

void RemoveOldDriver(void)
{
	LPDEVICE_INFO lpdi;
	LPDEVICE_INFO	lpDeviceInfo;
	char tempstr[MAX_DEVNODE_ID_LEN];
	int i;	        
	char szBuf[80];

// Look in Sound, Video and Game Controllers
	lpdi=NULL;
	if(DiGetClassDevsEx(&lpdi,"Media","PCI",NULL,DIGCF_PRESENT) == OK)
	{   
		if(lpdi)
		{
			DiBuildCompatDrvList(lpdi);
			DiBuildClassDrvList(lpdi);
		}
	    for ( lpDeviceInfo = lpdi ; lpDeviceInfo ; lpDeviceInfo = lpDeviceInfo->lpNextDi )
	    {      
	    	i=0;
	    	do
	    	{
	    		tempstr[i]=	toupper(lpDeviceInfo->szRegSubkey[i]);
	    		i++;
	    	}    
	    	while(lpDeviceInfo->szRegSubkey[i-1] != 0);
	
	    	if(strstr(tempstr,constVendorID) != NULL 
	    		&& strstr(tempstr,constDeviceID)  != NULL)
	    		{           
	    			if(lpDeviceInfo->lpCompatDrvList)
	    			{
		    			*szBuf=0;		// Initialize to blank file name
						GlobalGetAtomName(lpDeviceInfo->lpCompatDrvList->atInfFileName, szBuf, sizeof(szBuf));
						unlink(szBuf);
					}
	    			lpDeviceInfo->Flags |= DI_DONOTCALLCONFIGMG;		/* Has no effect but keep it here */
				    MessageBeep(-1);
	    			MessageBox(NULL,"Your system may hang during removal of TriMedia device.\n"
	    				"If your system hangs, reboot and then run tmmanins.exe again.",
	    				"Warning", MB_OK | MB_ICONINFORMATION | MB_SYSTEMMODAL);
					DiRemoveDevice(lpDeviceInfo);
				}
	
	//		DiSelectDevice(lpDeviceInfo);
	//		MessageBox(NULL,lpDeviceInfo->szDescription,"tmman",MB_OK);
		}
		DiDestroyDeviceInfoList(lpdi);
	}

// Look in Other Devices
	lpdi=NULL;
	if(DiGetClassDevsEx(&lpdi,"Unknown","PCI",NULL,DIGCF_PRESENT) == OK)
	{   
		if(lpdi)
		{
			DiBuildCompatDrvList(lpdi);
			DiBuildClassDrvList(lpdi);
		}
	    for ( lpDeviceInfo = lpdi ; lpDeviceInfo ; lpDeviceInfo = lpDeviceInfo->lpNextDi )
	    {      
	    	i=0;
	    	do
	    	{
	    		tempstr[i]=	toupper(lpDeviceInfo->szRegSubkey[i]);
	    		i++;
	    	}    
	    	while(lpDeviceInfo->szRegSubkey[i-1] != 0);
	
	    	if(strstr(tempstr,constVendorID) != NULL 
	    		&& strstr(tempstr,constDeviceID)  != NULL)
	    		{
	    			lpDeviceInfo->Flags |= DI_DONOTCALLCONFIGMG;
					DiRemoveDevice(lpDeviceInfo);
				}
	
	//		DiSelectDevice(lpDeviceInfo);
	//		MessageBox(NULL,lpDeviceInfo->szDescription,"tmman",MB_OK);
		}
		DiDestroyDeviceInfoList(lpdi);
	}
	
}
	
// Delete old VXD and DLL from Windows System directory
void DeleteOldFiles(void)
{
	WORD wReturn;
	int i;
	char szBuf[_MAX_PATH];
	char fileBuf[_MAX_PATH];
	char *filesToDelete[]={"vtmman.vxd","tmman.vxd","tmman32.dll","tmcrt.dll",
						"authhost.dll","tmcons.exe","tmrun.exe","tmmprun.exe"};
		
	wReturn = GetSystemDirectory((LPSTR) szBuf, sizeof(szBuf));
	 
	if (wReturn != 0)
	{
		for(i=0;i<sizeof(filesToDelete)/sizeof(char *);i++)
		{                                        
			sprintf(fileBuf,"%s\\%s",szBuf,filesToDelete[i]);
			if(access(fileBuf,0) == 0)		/* File Exists */
			{
				chmod(fileBuf,_S_IREAD | _S_IWRITE);
				unlink(fileBuf);
			}
		}  
// Delete Win98 WDM driver		
		sprintf(fileBuf,"%s32\\drivers\\tmman.sys",szBuf);
		if(access(fileBuf,0) == 0)		/* File Exists */
		{
			chmod(fileBuf,_S_IREAD | _S_IWRITE);
			unlink(fileBuf);
		}
	}
}

void InstallDriver(void)
{
    MessageBeep(-1);
	MessageBox(NULL,"To complete the driver installation,\nreboot and when Windows asks for a driver location,\n"
		"specify the directory Windows\\Data\\drivers\\Win9x on CD containing tmman9x.inf","Important",MB_OK | MB_ICONINFORMATION | MB_SYSTEMMODAL);
#if 0		
	DEVICE_INFO di;
	DRIVER_NODE dn;
	int i;	        
	char szBuf[80];
	ATOM atom;
	RETERR ret;

	di.cbSize=sizeof(DEVICE_INFO);
	di.lpNextDi=NULL;
	di.hRegKey=HKEY_LOCAL_MACHINE;
	strcpy(di.szClassName,"Media");
	
	dn.InfType=INFTYPE_TEXT;
	strcpy(dn.lpszDrvDescription,"TriMedia IREF Board");
	strcpy(dn.lpszHardwareID,"PCI\\VEN_1131&DEV_5400");
	atom=GlobalAddAtom("q:\\v2.0\\build\\win95\\bin\\win95\\tmman.inf");
	if (atom != 0)
	{
		dn.atInfFileName=atom;
		di.lpSelectedDriver=&dn;
		ret=DiInstallDevice(&di);
		if(ret == OK)
		{
		}
	}
#endif	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -