?? com.c
字號:
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <ctype.h>
#include <string.h>
#include "stock.h"
#include "Fstrcv.h"
#include "index.h"
#include "stockrcv.h"
#include "stock.h"
#include "demo.h"
#ifdef _DEBUG
FILE *fp=NULL;
#endif
HINSTANCE hLibrary=NULL;
HWND hWndBak;
UINT MsgBak;
//FARPROC lpFunction=NULL;
HANDLE m_hListenerThread;
char NewsPath[80];
int MsgCounter=0;
long Total=0L, Corent=0L;
unsigned long CardNumber=0;
extern void SendIndexMessage(int Market);
extern void SendStockMessage(int Market);
extern void ReceiveIndex(int Market);
extern void ReceiveStock(int Market);
extern void ReceiveNews();
extern void ReceiveMin();
FARPROC lpFunction_CtrlIntr=NULL;
FARPROC lpFunction_TestResult=NULL;
FARPROC lpFunction_ReceiveInfo=NULL;
FARPROC lpFunction_DataAcquisition=NULL;
long WINAPI Listener()
{
int i=1,j=0;
lpFunction_CtrlIntr = GetProcAddress(hLibrary, "CtrlIntr");
if(lpFunction_CtrlIntr==NULL)return 0;
lpFunction_TestResult = GetProcAddress(hLibrary, "TestResult");
if(lpFunction_TestResult==NULL)return 0;
lpFunction_ReceiveInfo = GetProcAddress(hLibrary, "ReceiveInfo");
if(lpFunction_ReceiveInfo==NULL)return 0;
lpFunction_DataAcquisition = GetProcAddress(hLibrary, "DataAcquisition");
if(lpFunction_DataAcquisition==NULL)return 0;
for(j=0;j<MAX_NEW_NUMBER;j++)
{
g_News[j].Address=0;
g_News[j].End=0;
g_News[j].Flag=0;
memset(g_News[j].Info,'\0',34);
g_News[j].InfoCode=0;
g_News[j].InfoLen=0;
g_News[j].LineNumber=0;
}
while(1)
{
// lpFunction = GetProcAddress(hLibrary, "CtrlIntr");
(* lpFunction_CtrlIntr)(0);
// lpFunction = GetProcAddress(hLibrary, "TestResult");
(* lpFunction_TestResult)(&Total, &Corent);
// lpFunction = GetProcAddress(hLibrary, "ReceiveInfo");
MsgCounter = (* lpFunction_ReceiveInfo)();
if(MsgCounter==0)
{
// lpFunction = GetProcAddress(hLibrary, "CtrlIntr");
(* lpFunction_CtrlIntr)(1);
continue;
}
for(i=0; i<MsgCounter; i++)
{
// lpFunction = GetProcAddress(hLibrary, "DataAcquisition");
if((* lpFunction_DataAcquisition)(i, &rs))
{
rs.Info[rs.InfoLength] = 0;
if((rs.Address == 0x12L) && (rs.AL == 2))
ReceiveIndex(SH_MARKET_EX);
else if( (rs.Address == 0x13L) && (rs.AL == 2) )
ReceiveIndex(SZ_MARKET_EX);
else if( (rs.Address == 0x2L) && (rs.AL == 1) )
ReceiveStock(SH_MARKET_EX);
else if( (rs.Address == 0x3L) && (rs.AL == 1) )
ReceiveStock(SZ_MARKET_EX);
else
if((rs.Address == 0x22L)&&(rs.AL == 2))
ReceiveMin();
else
if((rs.Address >= 0x0L) && (rs.Address <= 0x7L) && (rs.AL == 2))
ReceiveNews();
}
}
};
return 0;
}
BOOL CheckKey()
{
int i;
char BootValue[9]="12345678";
short Sum1=0;
short Sum2=0;
FILE *fp1=NULL;
char Temp[9];
char CardSerial[9];
char KeyValue[9];
for(i=0;i<8;i++)
{
if(((BootValue[i]-48)%2)==0)
Sum1+=BootValue[i]-48;
else
Sum2+=BootValue[i]-48;
}
sprintf(CardSerial,"%08ld",CardNumber);
if(CardSerial[7]%2)
for(i=0;i<4;i++)
Temp[i]=CardSerial[i*2+1];
else
for(i=0;i<4;i++)
Temp[i]=CardSerial[i*2];
sprintf(Temp+4,"%02d%02d",Sum1,Sum2);
for(i=0;i<8;i++)
{
if(Temp[i]=='0') Temp[i]='B';
if(Temp[i]=='1') Temp[i]='D';
if(Temp[i]=='2') Temp[i]='C';
if(Temp[i]=='3') Temp[i]='X';
if(Temp[i]=='4') Temp[i]='Z';
if(Temp[i]=='5') Temp[i]='J';
if(Temp[i]=='6') Temp[i]='Q';
if(Temp[i]=='7') Temp[i]='F';
if(Temp[i]=='8') Temp[i]='V';
if(Temp[i]=='9') Temp[i]='G';
}
Temp[8]='\0';
// 0,1,2,3,4,5,6,7,8,9
// B,D,C,X,Z,J,Q,F,V,G
fp1=fopen("C:\\key.txt","r");
if(fp1==NULL) return FALSE;
fread(KeyValue,8,1,fp1);
fclose(fp1);
KeyValue[8]='\0';
#ifdef _DEBUG
fprintf(fp,"KeyValue=%s\nTemp=%s\n",KeyValue,Temp);
fflush(fp);
#endif
if(strcmp(KeyValue,Temp)==0)return TRUE;
else return FALSE;
}
int WINAPI Stock_Init(HWND hWnd,UINT Msg,int nWorkMode)
{
unsigned long idThread;
FARPROC lpFunction=NULL;
#ifdef _DEBUG
fp=fopen("trace.txt","w+");
fprintf(fp,"------------Stock_Init Entering-----------------\n");
fflush(fp);
#endif
hLibrary = LoadLibrary("FstRcv.dll");
if(hLibrary == NULL)
return -1;
hWndBak=(HWND)hWnd;
MsgBak=Msg;
lpFunction = GetProcAddress(hLibrary, "InitRcv");
if(lpFunction==NULL)
return -1;
CardNumber = (* lpFunction)(hWnd,Msg);
if(!CheckKey()) return 1;
m_hListenerThread=CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)Listener,
(void *)hWnd,0,&idThread);//CREATE_SUSPENDED
if(!m_hListenerThread)
return -1;
return 1;
}
//extern "C"
int WINAPI Stock_Quit(HWND hWnd)
{
DWORD ExitCode;
#ifdef _DEBUG
fprintf(fp,"------------Stock_Quit Entering-----------------\n");
fflush(fp);
fclose(fp);
#endif
// lpFunction = GetProcAddress(hLibrary, "RetrieveCard");
// (* lpFunction)();
FreeLibrary(hLibrary);
if(GetExitCodeThread(m_hListenerThread,&ExitCode))
TerminateThread(m_hListenerThread,ExitCode);
return 1;
}
//extern "C"
int WINAPI SetupReceiver(BOOL bSetup)
{
return 1;
}
// nInfo == RI_IDSTRING, 返回特征字符串長度, pBuf 為特征字符串
// 如: "TongShi_StockDrv_1.00"
// nInfo == RI_IDCODE, 返回信息卡 ID 號, pBuf 為字符串形式的 ID 號
// 如: 0x78001234 "78001234"
// nInfo == RI_VERSION, 返回信息卡版本號, pBuf 為字符串版本
// 如: 1.00 "1.00"
//extern "C"
DWORD WINAPI GetStockDrvInfo(int nInfo,void * pBuf)
{
return RI_IDSTRING;
}
//extern "C"
void WINAPI SetNewsPath(LPCTSTR lpszNewsPath)
{
memcpy(NewsPath,lpszNewsPath,strlen(lpszNewsPath));
NewsPath[strlen(lpszNewsPath)]='\0';
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -