原理;用flash把书签相关信息写入剪贴板,用VC的程序读剪切板内容,写入硬盘。当flash读书签时,直接读取txt文件。写入或删除操作,用vc的程序。
=======================flash端:
按键设计: add | bookmark | del
限制:每本txt电子书只有一个书签。
src:
button add:
on(release){
//add
System.setClipboard("book1.txt" + '|' + content_txt.scroll);
fscommand("exec", "BookMark.exe");
}
button BookMark:
从txt读文件
button del:
让VC删掉记录book1书签的txt文件。
==========================VC端:
// BookMark.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "windows.h"
#include<string.h>
#define FILE_PATH TEXT(".//bookMark.txt")
BOOL getdate();
BOOL fbProcessBuf(CHAR *pSrc);
BOOL fbFileWrite(CHAR* pFile, CHAR* pBuff);
TCHAR aszBasePath[MAX_PATH];
int _tmain(int argc, _TCHAR* argv[])
{
ZeroMemory(aszBasePath, MAX_PATH*2);
GetCurrentDirectory(MAX_PATH, aszBasePath);
getdate();
//while(1);
return 0;
}
BOOL getdate()
{
HGLOBAL hglb;
LPTSTR lptstr;
CHAR aacTemp[MAX_PATH];
char *aaa =NULL;;
ZeroMemory(aacTemp,MAX_PATH);
if (!OpenClipboard(NULL))
//hwndMain换成你的主窗口句柄;
{
MessageBox(NULL, TEXT("Open Clipboard error!"), TEXT("Error"), MB_OK);
return FALSE;
}
hglb = GetClipboardData(CF_TEXT);
if (hglb != NULL)
{
aaa = (CHAR*)GlobalLock(hglb);
//lptstr = GlobalLock(hglb);
//printf("%s/n",(CHAR*)GlobalLock(hglb));
//WideCharToMultiByte(CP_ACP,0,lptstr,-1,aacTemp,MAX_PATH,NULL,NULL);
if (aaa != NULL)
{
//MessageBox(NULL, lptstr, TEXT("OK"), MB_OK);
fbProcessBuf(aaa);
//fbFileWrite(aaa);
GlobalUnlock(hglb);
}
}
CloseClipboard();
return TRUE;
}
BOOL fbProcessBuf(CHAR *pSrc)
{
CHAR* p = NULL;
p=strstr(pSrc,"|");
fbFileWrite(NULL,p+1);
return TRUE;
}
BOOL fbFileWrite(CHAR* pFile, CHAR* pBuff)
{
//TCHAR aatcConPath[MAX_PATH];
DWORD auWrite;
HANDLE ahConfig; /*File Handle*/
CHAR aacTemp[MAX_PATH];
//ZeroMemory(aatcConPath,MAX_PATH*2);
ZeroMemory(aacTemp,MAX_PATH);
auWrite=0;
//WideCharToMultiByte(CP_ACP,0,pBuff,-1,aacTemp,MAX_PATH,NULL,NULL);
//SetFileAttributes(aatcConPath,FILE_ATTRIBUTE_NORMAL);
SetCurrentDirectory(aszBasePath);
/*Set file attribute of only read existing*/
ahConfig=CreateFileW(FILE_PATH,
GENERIC_READ|GENERIC_WRITE,
FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL,
CREATE_ALWAYS,//CREATE_ALWAYS, //OPEN_EXISTING
NULL,
0);
if(INVALID_HANDLE_VALUE==ahConfig)
{
/*Read configure file failed*/
MessageBox(NULL, TEXT("CreateFile Error"), TEXT("Error"), MB_OK);
return FALSE;
}
SetFilePointer(ahConfig,0,0,FILE_END);
WriteFile(ahConfig,pBuff,strlen(pBuff),&auWrite,NULL);
//SetFileAttributes(aatcConPath,FILE_ATTRIBUTE_READONLY);
CloseHandle(ahConfig);
return true;
}
没写完...