MFC 串列埠傳送檔案

2021-06-21 11:00:46 字數 948 閱讀 6632

以下**在龔建偉的串列埠原始碼**上修改而來!

因為龔建偉的串列埠原始碼傳送檔案錯誤,故作了下修改,可以傳送檔案了,希望可以幫助到需要的童鞋們!

經過除錯,終於把這段**給寫好啦!

先通過乙個button 開啟乙個檔案,然後通過檔案函式,把開啟的檔案讀到乙個指標buffer中,再利用串列埠函式把讀到的資料傳送出去。

在此注意:用串列埠傳送函式時,用這個函式(因為是指標資料,所以需要指出檔案的長度fplength):

m_port.writetoport((lpctstr)fpbuff,fplength); //傳送資料//開啟檔案

void cserialdlg::onbnclickedbutton6()

}

//傳送檔案

void cserialdlg::onbnclickedbutton8()

fp.seektoend();

unsigned long fplength=fp.getlength();

m_nfilelength=fplength;

char* fpbuff=null;

fpbuff=new char[fplength];

fp.seektobegin();

if(fp.read(fpbuff,fplength)<1)

fp.close();

if(m_port.m_hcomm==null)

else

else

cstring strtemp;

strtemp.format("tx:%d",tx_count);

m_ctrltxcount.setwindowtext(strtemp);

delete fpbuff; }

}

MFC 串列埠傳送檔案

mfc 串列埠傳送檔案 以下 在龔建偉的串列埠原始碼 上修改而來!因為龔建偉的串列埠原始碼傳送檔案錯誤,故作了下修改,可以傳送檔案了,希望可以幫助到需要的童鞋們!經過除錯,終於把這段 給寫好啦!先通過乙個button 開啟乙個檔案,然後通過檔案函式,把開啟的檔案讀到乙個指標buffer中,再利用串列...

基於mfc的簡單的串列埠助手,傳送接收

pragma once include com.h class ccomdlgdlg public cdialog protected virtual void dodataexchange cdataexchange pdx ddx ddv 支援 實現 protected hicon m hico...

MFC 遍歷串列埠

遍歷串列埠實現 cstring ccomdialog findallcom hkey hkey int rtn cstring cominfo int i 0 dword dwlong,dwsize char portname 256 commname 256 rtn regopenkeyex hk...