技术论坛

 wincc读处方与写处方原程序

返回主题列表
作者 主题
珠峰
游士

经验值:213
发帖数:41
精华帖:1
楼主    2005-11-11 08:35:05
主题:wincc读处方与写处方原程序 精华帖 
读处方:
#include "apdefap.h"
void OnClick(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName)
{

#pragma code ("comdlg32.dll")
#include "commdlg.h"
#pragma code()

BOOL bRet;
OPENFILENAME ofn;
char szFilter[] = "Textfiles*.txtAll Files*.*";
char* psz;
char szFile[_MAX_PATH+1];
char szInitialDir[_MAX_PATH+1] = "C:\\";

ofn.lStructSize = sizeof(OPENFILENAME);

ofn.hwndOwner = FindWindow(NULL,"XSJ");

for (psz = szFilter; *psz; psz++)
{
if (*psz == '')
{
*psz = 0;
}
}
ofn.lpstrFilter = szFilter;

ofn.lpstrFile = szFile;
ofn.nMaxFile = _MAX_PATH+1;

GetProjectPath(szInitialDir); //if function fails initial
//directory is "C:\\"
ofn.lpstrInitialDir = szInitialDir;

bRet = GetOpenFileName(&ofn);


{
FILE* pFile = NULL;
char szFile1[_MAX_PATH+10];
int i;


//create file name
strcpy(szFile1,ofn.lpstrFile);


//open file to read
pFile = fopen(szFile1,"r+");

//check return value of fopen()
if (pFile == NULL)
{
printf("\r\nError in fopen()\r\n");
return;
}

//read data
//set data

fscanf(pFile,"%d\r\n",&i);
SetTagSDWord("imb136",i);
fscanf(pFile,"%d\r\n",&i);
SetTagSDWord("mw470",i); //Return-Type :WORD

fclose(pFile); //Return-Type :long int
}
}


写处方:
#include "apdefap.h"
void OnClick(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName)
{

#pragma code ("comdlg32.dll")
#include "commdlg.h"
#pragma code()

BOOL bRet;
OPENFILENAME ofn;
char szFilter[] = "Textfiles*.txtAll Files*.*";
char* psz;
char szFile[_MAX_PATH+1];
char szFileTitle[_MAX_PATH+1] = "Unnamed.txt";
char szInitialDir[_MAX_PATH+1] = "C:\\";

ofn.lStructSize = sizeof(OPENFILENAME);

ofn.hwndOwner = FindWindow(NULL,"XSJ");

for (psz = szFilter; *psz; psz++)
{
if (*psz == '')
{
*psz = 0;
}
}
ofn.lpstrFilter = szFilter;

ofn.lpstrFile = szFile;
ofn.nMaxFile = _MAX_PATH+1;

ofn.lpstrFileTitle = szFileTitle;
ofn.nMaxFileTitle = _MAX_PATH+1;

GetProjectPath(szInitialDir); //if function fails initial
//directory is "C:\\"
ofn.lpstrInitialDir = szInitialDir;

ofn.Flags = OFN_OVERWRITEPROMPTOFN_PATHMUSTEXIST;

ofn.lpstrDefExt = "txt";

bRet = GetSaveFileName(&ofn);

{
FILE* pFile = NULL;
char szFile1[_MAX_PATH+10];
int i;

//create file name
strcpy(szFile1,ofn.lpstrFileTitle);

//open or create file to write
pFile = fopen(szFile1,"w+");

//get data to write
//write data

i=GetTagSDWord("imb136");
fprintf(pFile,"%d\r\n",i);

i=GetTagSDWord("imw140");
fprintf(pFile,"%d\r\n",i);

fclose(pFile); //Return-Type :long int
}

}
您收到0封站内信:
×
×
信息提示
很抱歉!您所访问的页面不存在,或网址发生了变化,请稍后再试。