|
I have source code for a DLL created in C++ .net, I want to debug this.
I have created a second project (console application ) in the same solution ,for calling a particular function from the first project and passing parameter to it.
But when I tried to call that function
int DNAPrintExport InstallPrinter(const char* cpstrPrinterData)
{
}
using the following code in the second project
int abc=InstallPrinter("Hello");
I am getting error C2065: 'InstallPrinter' : undeclared identifier
Can anybody help me to do this please
Thanks in advance
Jayakrishnan
|
|
|
|
|
Have a look here[^] and see how _declspec(dllimport) is used to import a function from a DLL to another application.
|
|
|
|
|
Dear all,
I am using Visual C MFC Dialog-based application to obtain USB data from a Cypress chip. DeviceIoControl(IOCTL_EZUSB_BULK_READ...)... I am doing this using multithreading method. However, I face a problem when I compile. This is part of my program:
UINT SendOpThread(LPVOID pParam)
{
int bResult;
CThreadInfo* pTh = (CThreadInfo*)pParam;
BULK_TRANSFER_CONTROL2 btc;
btc.pipeNum = 0;
DeviceHandle = CreateFile("\\\\.\\ezusb-0",
GENERIC_WRITE,
FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
0,
NULL);
bResult = DeviceIoControl (DeviceHandle,
IOCTL_EZUSB_BULK_READ,
&btc,
sizeof (BULK_TRANSFER_CONTROL),
r_Buffer,
sizeof(r_Buffer),
&nBytes,
NULL);
CloseHandle(DeviceHandle);
wsprintf(str, "r_Buffer[%d]: %04X\n", i,r_Buffer[i]);
SendDlgItemMessage(IDC_OUTPUT6,
LB_ADDSTRING,
0,
(LPARAM)(LPCTSTR) str);
return(bResult);
}
void CUSB1Dlg::OnBulkRead()
{
// TODO: Add your control notification handler code here
int Code=1;
stream1 = fopen("data.txt","a+") ;
myWinThread = AfxBeginThread(SendOpThread, &Code, THREAD_PRIORITY_HIGHEST,0,CREATE_SUSPENDED);
myWinThread->m_bAutoDelete=FALSE;
myWinThread->ResumeThread();
.
.
.
}
When I compile, I got this error:
'SendDlgItemMessageA' : Function does not take 4 parameters
I found from the Help:
SendDlgItemMessage consists of 3 types: which is CWnd, CWindow, & Windows User Interface. Which 1 should the thread belongs to?
I assumed that it belongs to WUI, and so it requires HWND hDlg, a handle of dialog box. Since I am using Dialog-based application where the dialog is already created, how should I put for the hdlg parameter?
I really wish that someone could help me...
Einly
|
|
|
|
|
OK, here's my 2 cents worth. You can change the code slightly by using
CWnd* pWnd = GetDlgItem(IDC_OUTPUT6);
if (pWnd)
{
pWnd->SendMessage(LB_ADDSTRING, 0, (LPARAM)(LPCTSTR)str);
}
assuming, of course, this happens in a dialog member function.
If not, and it's in something like a worker thread, as part of the thread parameter block, you need something more complex than a simple int.
Perhaps
struct paramblock {
int code;
HWND hWnd;
};
would help
Then get the HWND before invoking the AfxBeginThread, and use the WINAPI version.
As a rule, you can specify you want that version by using the global scope prefix '::'
eg ::SendMessage(param.hWnd, LB_ADDSTRING, 0, (LPARAM)(LPCTSTR)str);
Hope this helps
Steve S
|
|
|
|
|
Thanks for your reply. Sorry that I am quite poor in Visual C. May I know how do I get hWnd? hWnd=??? My objective is to output some message in my worker thread. So, let say...
UINT SendOpThread(LPVOID pParam)
{
int bResult;
CThreadInfo* pTh = (CThreadInfo*)pParam;
BULK_TRANSFER_CONTROL2 btc;
btc.pipeNum = 0;
DeviceHandle = CreateFile("\\\\.\\ezusb-0",
GENERIC_WRITE,
FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
0,
NULL);
bResult = DeviceIoControl (DeviceHandle,
IOCTL_EZUSB_BULK_READ,
&btc,
sizeof (BULK_TRANSFER_CONTROL),
r_Buffer,
sizeof(r_Buffer),
&nBytes,
NULL);
CloseHandle(DeviceHandle);
wsprintf(str, "r_Buffer[%d]: %04X\n", i,r_Buffer[i]);
::SendDlgItemMessage(pParam2.hWnd, LB_ADDSTRING,
0,
(LPARAM)(LPCTSTR) str);
return(bResult);
}
void CUSB1Dlg::OnBulkRead()
{
// TODO: Add your control notification handler code here
struct paramblock{
int Code=1;
HWND hWnd;
};
What should I write here?
stream1 = fopen("data.txt","a+") ;
myWinThread = AfxBeginThread(SendOpThread, here??pPar, THREAD_PRIORITY_HIGHEST,0,CREATE_SUSPENDED);
myWinThread->m_bAutoDelete=FALSE;
myWinThread->ResumeThread();
.
.
.
}
Einly
|
|
|
|
|
Thanks for your reply. Sorry that I am quite poor in Visual C. May I know how do I get hWnd? hWnd=??? My objective is to output some message in my worker thread. So, let say...
UINT SendOpThread(LPVOID pParam)
{
int bResult;
CThreadInfo* pTh = (CThreadInfo*)pParam;
BULK_TRANSFER_CONTROL2 btc;
btc.pipeNum = 0;
DeviceHandle = CreateFile("\\\\.\\ezusb-0",
GENERIC_WRITE,
FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
0,
NULL);
bResult = DeviceIoControl (DeviceHandle,
IOCTL_EZUSB_BULK_READ,
&btc,
sizeof (BULK_TRANSFER_CONTROL),
r_Buffer,
sizeof(r_Buffer),
&nBytes,
NULL);
CloseHandle(DeviceHandle);
wsprintf(str, "r_Buffer[%d]: %04X\n", i,r_Buffer[i]);
::SendMessage(pParam2.hWnd, LB_ADDSTRING,
0,
(LPARAM)(LPCTSTR) str);
return(bResult);
}
void CUSB1Dlg::OnBulkRead()
{
// TODO: Add your control notification handler code here
struct paramblock{
int Code=1;
HWND hWnd;
};
What should I write here?
stream1 = fopen("data.txt","a+") ;
myWinThread = AfxBeginThread(SendOpThread, here??pPar, THREAD_PRIORITY_HIGHEST,0,CREATE_SUSPENDED);
myWinThread->m_bAutoDelete=FALSE;
myWinThread->ResumeThread();
.
.
.
}
Einly
|
|
|
|
|
im trying to construct a GDI+ Image object from an IStream;
the IStream is created on global memory successfully and assigned valid image data but, when i try
image = ::new Image(stream)
laststatus says something about wrong/incorrect arguments
("InvalidParameter" i think)
has anybody tried this ?
|
|
|
|
|
Did you rewind the stream? I.e. pStream->Seek(0, STREAM_SEEK_SET, 0)?
--
Try walking in my shoes. You stumble in my footsteps.
|
|
|
|
|
never knew i had to !
Thank you for the hint - will give it a try
|
|
|
|
|
I've run into that problem a couple of times.
--
Try walking in my shoes. You stumble in my footsteps.
|
|
|
|
|
nope, doesnt work still
the GDI+ Image still has property nativeImage = 0x00
and lastResult is InvalidParameter
any other ideas ?
|
|
|
|
|
Sorry, I'm out of ideas.
--
Try walking in my shoes. You stumble in my footsteps.
|
|
|
|
|
thanx, Jörgen
i think i found the cause - its actually not the IStream, but the GIF image data inside of it that makes the Image constructor fail. When i exported the GIF image and saved it anew (in acdsee) - the new file is slightly different and Image aquires it without problems.
I'll be digging it some more, but its a different matter now
thanx again
see you around
|
|
|
|
|
Hello,
can please someone explain me, how modeless dialogs are working ?
Does they have their own message queue ?
Which thread is processing their messages ? (When I have one threaded
application which just created couple od modeless dialogs) ?
rrrado
|
|
|
|
|
Message Q's are on a per-thread basis - each modeless dialog your thread creates will be serviced by the same message Q - it's the magic call(s) to IsDialogMessage in the message pump that translates the keyboard messages for each dialog.
|
|
|
|
|
Thanks !
rrrado
|
|
|
|
|
I make an Application running on PocketPC, but I don't know how to get current directory for my App.
Ex: I put my App in \Program files\MyApp\
When I change its location, I can't read my data file in the newfolder!
Ex: I change its location to: \MyApp1\
HonestRing
|
|
|
|
|
GetModuleFileName will give you the path and filename, all you'll need to do is strip the filename from the end and replace it with your data file name.
Have a look on MSDN for more info, as the function may not be supported by all devices.
Michael
But you know when the truth is told,
That you can get what you want or you can just get old,
Your're going to kick off before you even get halfway through.
When will you realise... Vienna waits for you? - "The Stranger," Billy Joel
|
|
|
|
|
I am working on a functionality just opposite to what the Microsoft Depends does. Rather than finding out the dependencies of an exe/dll I need to list down the exe's/dll's dependent upon a particular function in a library.
Is there any such utility available? Or can I get some help on the same?
|
|
|
|
|
Hi everybody,
I would like to know if someone could tell me if a debugger made to find memory leak problem exist for windows environment & if it's ok where i could find it? Some of my friends tell me about a software called "valgrind" which only works under linux environment!
Thanks in advance for yours answers
Gerald
|
|
|
|
|
If your app uses MFC, you can use the DEBUG_NEW macro, and memory leaks will be outputted to your Output windows in Visual Studio. This even tells you the line of code where the object was "new"ed.
At top of all .cpp files:
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
|
|
|
|
|
What is the difference between CSocket and CAsyncSocket
Accrding to MSDN CSocket is a blocking socket and CAsynSocket is a non blocking socket from it what i understood that for example if u make a call on CSocket Recieve it will not return untill u get the whole data (which is wrong when data is on average > 5 k u have to make multiple recieve call to fetch the whole data)
but in case of CAsyncSocket u will have to loop to get whole data .
but another joke written in MSDN is that one should not make multiple recieve calls in OnRecieve while using CSocket::Recieve cauz CSocket is internally dooing looping to recieve whole data.
but with single call u cannot get the whole data atonce. so result of it's is that CSocket becomes useless after transferring 40 , 50 k data on average.
so can anybody explain this scneriao . what is the best way to recieve data in OnRecieve and what socket should i use CSocket or CAsyncSocket.
Note:i am writing a Video streaming software so server on average sends me data range from 5 to 15 k /sec .what i do in OnRecieve is asfollows
do//i am using CSocket
{
res=Receive(ptr,lLength);//where ptr is buffer of size of incoming data
if(res==SOCKET_ERROR)
{
Close();
break;
}
ptr+=res;
total+=res;
}
while(total<lLength);//lLength is size of incoming data
in this case according to msdn i am making multiple recieve call which is wrong , but the reason for it is that i am not able to recieve whold data with one Recive call .
but the result of this code is that it works for hardly 10 to 12 frames. and i have to reconnect again.
No Worries!
|
|
|
|
|
I would try to stay away from CSocket and CAsyncSocket (I have ran into lots of problems with both).. If you use standard WinSock and stay away from those wrapper classes it would be much easier.
Here is a example of how I might do the loop..
char buff[4096];
int nRec;
while(nRec = recv(client,buff,sizeof(buff),0))
{
if((nRec == SOCKET_ERROR) && (nRec != WSAEWOULDBLOCK))
{
}
else
{
}
}
Hope this helps..
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
But is it possible to get OnReceive , OnClose like event notifications using WINSOK , can u refer me some good code regarding this.
No Worries!
|
|
|
|
|
Yep you can get all those notifications.. Look around in CodeProject under Internet & Network there are quite a few articles from basic to advanced.. I will dig through my favorites when I get into work and email you some URL's with examples and good reading..
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|