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

📄 tvichw32ctl.h

📁 《Delphi5企业级解决方案及应用剖析》参考程序 DELPHI 资料集
💻 H
字号:
#if !defined(AFX_TVICHW32CTL_H__0EAC1572_1FEB_11D2_B035_00A0C9184FF9__INCLUDED_)
#define AFX_TVICHW32CTL_H__0EAC1572_1FEB_11D2_B035_00A0C9184FF9__INCLUDED_

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000

#include <winsvc.h>


#define MaxMappedAreas 16

// TVicHW32Ctl.h : Declaration of the CTVicHW32Ctrl ActiveX Control class.


typedef struct _LockedMemory {
	DWORD   Drv_IRQ_Counter;
	WORD    ScanCode;
	WORD    MAX_BUF_LPT;
	WORD    LPT_BASE_PORT;
	WORD    L_BUF_LPT;
	WORD    N_ADD_LPT;
	WORD    N_SEL_LPT;
    WORD    BUF_LPT[1];
} TLockedBuffer, *PLockedBuffer;

/////////////////////////////////////////////////////////////////////////////
// CTVicHW32Ctrl : See TVicHW32Ctl.cpp for implementation.

class CTVicHW32Ctrl : public COleControl
{
	DECLARE_DYNCREATE(CTVicHW32Ctrl)

// Constructor
public:
	CTVicHW32Ctrl();

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CTVicHW32Ctrl)
	public:
	virtual void OnDraw(CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid);
	virtual void DoPropExchange(CPropExchange* pPX);
	virtual void OnResetState();
	//}}AFX_VIRTUAL

// Implementation
protected:
	~CTVicHW32Ctrl();

	BOOL      InstallDriver();
	BOOL      StartDriver();
	BOOL      StopDriver();
	BOOL      RemoveDriver();
	void      CloseStopUnloadDriver();
	void      InstallStartLoadDriver();
	long      CtlCode(long Code);
	void      ClearFields();
    friend 
	void __stdcall IRQProcNT(CTVicHW32Ctrl& HW32);
    friend 
	void __stdcall IRQProc95(CTVicHW32Ctrl& HW32);

    HANDLE    hDrv;
	HMODULE   hDll;

	BOOL      fWin95;
	BOOL      fRegistry;
	BOOL      fStarted;

    SC_HANDLE schSCManager;

    BOOL	  fTerminated;

    ULONG	  fInterface;     // Isa, Eisa, etc....
    ULONG	  fBus;			// Bus number
    ULONG	  fPhysLoPart;    // Bus-relative address
    ULONG     fPhysHiPart;    // Zero
    ULONG	  fTypeMem;       // 0 is memory, 1 is I/O
    ULONG	  fMemorySize;    // Length of section to map

    PVOID	  fMappedPointers[MaxMappedAreas];
    ULONG     fMappedSizes[MaxMappedAreas];
	ULONG     fMappedAddresses[MaxMappedAreas];
	short     fMappedAreas;

    PVOID     fpLockedMemory;
	PVOID     fMdl;

    HANDLE	  fLocEvent;

	long      fDebugCode;
    	
    BOOL	  fHardAccess;
   
    BOOL      fOpenDrive;

    void	(*fOnHWInterrupt)();
    short	  fIRQNumber;
	BOOL      fIsIRQSet;
    BOOL      fMasked;
    HANDLE	  fThreadId;
    HANDLE	  fThreadHandle;
    
    WORD     *fLPTAddresses;
	WORD      fLPTBasePort;
	BYTE      fDataPorts[3];
	BYTE      fLPTNumber;
	BYTE      fLPTs;

	DECLARE_OLECREATE_EX(CTVicHW32Ctrl)    // Class factory and guid
	DECLARE_OLETYPELIB(CTVicHW32Ctrl)      // GetTypeInfo
	DECLARE_PROPPAGEIDS(CTVicHW32Ctrl)     // Property page IDs
	DECLARE_OLECTLTYPE(CTVicHW32Ctrl)		// Type name and misc status

// Message maps
	//{{AFX_MSG(CTVicHW32Ctrl)
		// NOTE - ClassWizard will add and remove member functions here.
		//    DO NOT EDIT what you see in these blocks of generated code !
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()

// Dispatch maps
	//{{AFX_DISPATCH(CTVicHW32Ctrl)
	afx_msg BOOL GetHardAccess();
	afx_msg void SetHardAccess(BOOL bNewValue);
	afx_msg short GetLPTNumber();
	afx_msg void SetLPTNumber(short nNewValue);
	afx_msg BOOL GetIRQMasked();
	afx_msg void SetIRQMasked(BOOL bNewValue);
	afx_msg short GetIRQNumber();
	afx_msg void SetIRQNumber(short nNewValue);
	afx_msg short GetLPTNumPorts();
	afx_msg short GetLPTBasePort();
	afx_msg BOOL GetLPTAckwl();
	afx_msg BOOL GetLPTBusy();
	afx_msg BOOL GetLPTPaperEnd();
	afx_msg BOOL GetLPTSlct();
	afx_msg BOOL GetLPTError();
	afx_msg BOOL GetActiveHW();
	afx_msg short GetMappedAreas();
	afx_msg void CloseDriver();
	afx_msg BOOL OpenDriver();
	afx_msg long MapPhysToLinear(long PhAddr, long PhSize);
	afx_msg void UnmapMemory(long PhAddr, long PhSize);
	afx_msg void LPTStrobe();
	afx_msg void LPTAutofd(BOOL Flag);
	afx_msg void LPTInit();
	afx_msg void LPTSlctIn();
	afx_msg BOOL LPTPrintChar(short ch);
	afx_msg long DebugCode();
	afx_msg short GetPort(short PortAddr);
	afx_msg void SetPort(short PortAddr, short nNewValue);
	afx_msg short GetPortW(short PortAddr);
	afx_msg void SetPortW(short PortAddr, short nNewValue);
	afx_msg long GetPortL(short PortAddr);
	afx_msg void SetPortL(short PortAddr, long nNewValue);
	afx_msg BOOL GetPin(short nPin);
	afx_msg void SetPin(short nPin, BOOL bNewValue);
	afx_msg short GetMem(long MappedAddr, long Offset);
	afx_msg void SetMem(long MappedAddr, long Offset, short nNewValue);
	afx_msg short GetMemW(long MappedAddr, long Offset);
	afx_msg void SetMemW(long MappedAddr, long Offset, short nNewValue);
	afx_msg long GetMemL(long MappedAddr, long Offset);
	afx_msg void SetMemL(long MappedAddr, long Offset, long nNewValue);
	//}}AFX_DISPATCH
	DECLARE_DISPATCH_MAP()

// Event maps
	//{{AFX_EVENT(CTVicHW32Ctrl)
	void FireOnHwInterrupt(long HwCounter, short LPT_DataReg, short LPT_StatusReg, short ScanCode)
		{FireEvent(eventidOnHwInterrupt,EVENT_PARAM(VTS_I4  VTS_I2  VTS_I2  VTS_I2), HwCounter, LPT_DataReg, LPT_StatusReg, ScanCode);}
	//}}AFX_EVENT
	DECLARE_EVENT_MAP()

// Dispatch and event IDs
public:
	enum {
	//{{AFX_DISP_ID(CTVicHW32Ctrl)
	dispidHardAccess = 1L,
	dispidLPTNumber = 2L,
	dispidIRQMasked = 3L,
	dispidIRQNumber = 4L,
	dispidLPTNumPorts = 5L,
	dispidLPTBasePort = 6L,
	dispidLPTAckwl = 7L,
	dispidLPTBusy = 8L,
	dispidLPTPaperEnd = 9L,
	dispidLPTSlct = 10L,
	dispidLPTError = 11L,
	dispidActiveHW = 12L,
	dispidMappedAreas = 13L,
	dispidCloseDriver = 14L,
	dispidOpenDriver = 15L,
	dispidPort = 24L,
	dispidPortW = 25L,
	dispidPortL = 26L,
	dispidMapPhysToLinear = 16L,
	dispidUnmapMemory = 17L,
	dispidLPTStrobe = 18L,
	dispidLPTAutofd = 19L,
	dispidLPTInit = 20L,
	dispidLPTSlctIn = 21L,
	dispidLPTPrintChar = 22L,
	dispidPin = 27L,
	dispidMem = 28L,
	dispidMemW = 29L,
	dispidMemL = 30L,
	dispidDebugCode = 23L,
	eventidOnHwInterrupt = 1L,
	//}}AFX_DISP_ID
	};
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_TVICHW32CTL_H__0EAC1572_1FEB_11D2_B035_00A0C9184FF9__INCLUDED)

⌨️ 快捷键说明

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