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