Click here to Skip to main content
16,006,475 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Waiting for an application to finish Pin
Atlantys16-Dec-02 10:06
Atlantys16-Dec-02 10:06 
GeneralRe: Waiting for an application to finish Pin
Navin16-Dec-02 10:11
Navin16-Dec-02 10:11 
GeneralRe: Waiting for an application to finish Pin
Atlantys16-Dec-02 11:09
Atlantys16-Dec-02 11:09 
GeneralRe: Waiting for an application to finish Pin
Todd Smith16-Dec-02 18:59
Todd Smith16-Dec-02 18:59 
GeneralDll Help...... Pin
keb16-Dec-02 9:20
keb16-Dec-02 9:20 
GeneralRe: Dll Help...... Pin
Rickard Andersson2016-Dec-02 9:26
Rickard Andersson2016-Dec-02 9:26 
GeneralRe: Dll Help...... Pin
Alvaro Mendez16-Dec-02 9:29
Alvaro Mendez16-Dec-02 9:29 
GeneralRe: Dll Help...... Pin
keb16-Dec-02 10:04
keb16-Dec-02 10:04 
Wow, I can't get over the fact how quickly I get some help. Thanks guys. And here is more of the code we used which is failing. I guess I should have just cut and paste rather than typing things in... Also the idea behind here is that I am trying to que up a message that I recieve from a hardware and my co-worker is trying to read message and get rid of the memory space after he reads. What would be the best way to achieve this? Is creating a dll to do this work bad idea?

co-workers' side:
void CViapcDlg::OnConnect()
{
char errMsg[MAX_PATH];
DWORD result;

hLib=LoadLibrary(COMMDLLNAME);
DLL_LOAD = TRUE;
if(hLib==NULL)
{
AfxMessageBox(errMsg);
DLL_LOAD = FALSE;
}
else
{
char COMPORT[MAX_PATH];
int comport;
memset(COMPORT,0,MAX_PATH);
m_pHDContainer = new THDContainer();
m_pCommandArray = new CArray <tcommandarray,tcommandarray &="">();
m_pCommandArray->SetSize(0, 10);
m_pHDContainer->ONLINE = false;
for(int i =0; i < 5; i++)
{
if(m_COMPort[i]->GetCheck())
comport = i+1;
m_COMPort[i]->EnableWindow(FALSE);
}
wsprintf(COMPORT, "\\\\.\\COM%d", comport);
lpfnInit = (LPFNINIT)GetProcAddress((HMODULE)hLib, "InitProcessor");
lpfnClose = (LPFNCLOSE)GetProcAddress((HMODULE)hLib, "CloseProcessor");
lpfnProcessor = (LPFNPROCESSOR)GetProcAddress((HMODULE)hLib, "Processor");
lpfnAdd = (LPFNADD)GetProcAddress((HMODULE)hLib, "Add");

if(lpfnInit)
result = lpfnInit((LPCSTR)COMPORT, this->m_hWnd, m_pHDContainer, m_pCommandArray);
}

}

void CViapcDlg::OnMessage(WPARAM wparam, LPARAM lparam)
{
while(m_pCommandArray->GetSize())
{
TCommandArray insertData = m_pCommandArray->GetAt(0);
m_pCommandArray->RemoveAt(0);
do things with data here...
}
}

void CViapcDlg::Close()
{
if(hLib)
FreeLibrary((HMODULE)hLib); <----------- Memory leak here

if(m_pHDContainer)
{
delete m_pHDContainer;
}

if(m_pCommandArray)
{
delete m_pCommandArray; <---------- Access violatioin error here
}
}

My side:
int InitProcessor(LPSTR lpPortName, HWND hWnd, THDContainer *pHDContain, CArray <tcommandarray,tcommandarray &=""> *pHDMsg)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
thread stuff here to get info from a hardware and add stuff into array;
TCommandArray data;
data.type1 = 1;
data.type2 = 2;
data.type3 = 3;

pHDMsg->add(data);
::PostMessage( hWnd, COMDLL_MESSAGE, 0, 1);
return 0;
}
GeneralRe: Dll Help...... Pin
Alvaro Mendez16-Dec-02 10:25
Alvaro Mendez16-Dec-02 10:25 
GeneralRecent File List Pin
will138316-Dec-02 8:28
will138316-Dec-02 8:28 
GeneralRe: Recent File List Pin
Gary Kirkham16-Dec-02 8:44
Gary Kirkham16-Dec-02 8:44 
GeneralRe: Recent File List Pin
will138316-Dec-02 8:56
will138316-Dec-02 8:56 
GeneralRe: Recent File List Pin
Gary Kirkham16-Dec-02 9:05
Gary Kirkham16-Dec-02 9:05 
GeneralRe: Recent File List Pin
will138316-Dec-02 9:17
will138316-Dec-02 9:17 
GeneralList Control Problem Pin
sikrip16-Dec-02 7:26
sikrip16-Dec-02 7:26 
GeneralRe: List Control Problem Pin
valikac16-Dec-02 8:04
valikac16-Dec-02 8:04 
Generalread/write datas from TCP/IP Pin
youssef16-Dec-02 7:23
youssef16-Dec-02 7:23 
GeneralRe: read/write datas from TCP/IP Pin
User 665816-Dec-02 7:37
User 665816-Dec-02 7:37 
GeneralRe: read/write datas from TCP/IP Pin
Jörgen Sigvardsson16-Dec-02 11:40
Jörgen Sigvardsson16-Dec-02 11:40 
GeneralOwner-drawn menus Pin
RobinBobin16-Dec-02 6:31
RobinBobin16-Dec-02 6:31 
GeneralRe: Owner-drawn menus Pin
Alvaro Mendez16-Dec-02 7:13
Alvaro Mendez16-Dec-02 7:13 
GeneralBuild Question.. Quickie... Pin
Ryan B.16-Dec-02 5:46
Ryan B.16-Dec-02 5:46 
GeneralRe: Build Question.. Quickie... Pin
Magius9616-Dec-02 5:50
Magius9616-Dec-02 5:50 
GeneralRe: Build Question.. Quickie... Pin
Ryan B.16-Dec-02 5:53
Ryan B.16-Dec-02 5:53 
GeneralRe: Build Question.. Quickie... Pin
Alvaro Mendez16-Dec-02 5:53
Alvaro Mendez16-Dec-02 5:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.