发布于 2014-05-20 08:35:04
7楼
C代码
#include "apdefap.h"
void OnClick(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName)
{
//#pragma option(mbcs)
typedef struct tagOFN { // ofn
DWORD lStructSize;
HWND hwndOwner;
HINSTANCE hInstance;
LPCTSTR lpstrFilter;
LPTSTR lpstrCustomFilter;
DWORD nMaxCustFilter;
DWORD nFilterIndex;
LPTSTR lpstrFile;
DWORD nMaxFile;
LPTSTR lpstrFileTitle;
DWORD nMaxFileTitle;
LPCTSTR lpstrInitialDir;
LPCTSTR lpstrTitle;
DWORD Flags;
WORD nFileOffset;
WORD nFileExtension;
LPCTSTR lpstrDefExt;
DWORD lCustData;
DWORD lpfnHook; // LPOFNHOOKPROC lpfnHook;
LPCTSTR lpTemplateName;
} OPENFILENAME,*LPOPENFILENAME;
#pragma code ("comdlg32.dll")
BOOL GetOpenFileNameA(LPOPENFILENAME lpofn) ;
#pragma code()
HWND hwnd;
BOOL bRet;
OPENFILENAME ofn;
char szFile[_MAX_PATH+1];
hwnd=FindWindow(NULL,"WinCC-Runtime - ");
//printf("WinCC-Runtime hwnd=%d\r\n",hwnd);
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hwnd;
ofn.lpstrFile = szFile;
ofn.lpstrFilter="Excel文件(*.xls)\0*.xls\0";
ofn.nFilterIndex = 1;
ofn.lpstrInitialDir= "D:\\";
ofn.nMaxFile = _MAX_PATH+1;
bRet = GetOpenFileNameA(&ofn);
if (bRet == FALSE)
{
printf("\r\nError in GetOpenFileName()\r\n");
return;
}
printf("\r\nSelected File (Full Path) is:\r\n%s\r\n",ofn.lpstrFile);
SetText(lpszPictureName,"StaticText_FileName",ofn.lpstrFile);
无论成与败,无论甜与苦,我还是我。