wincc读处方与写处方原程序

已锁定

珠峰

  • 帖子

    41
  • 精华

    1
  • 被关注

    3

论坛等级:游士

注册时间:2004-11-03

普通 普通 如何晋级?

wincc读处方与写处方原程序

1853

7

2005-11-11 08:35:05

读处方:
#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
}

}
wincc读处方与写处方原程序 已锁定
编辑推荐: 关闭

请填写推广理由:

本版热门话题

SIMATIC WinCC / Panel

共有32654条技术帖

相关推荐

热门标签

相关帖子推荐

guzhang

恭喜,你发布的帖子

评为精华帖!

快扫描右侧二维码晒一晒吧!

再发帖或跟帖交流2条,就能晋升VIP啦!开启更多专属权限!

  • 分享

  • 只看
    楼主

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