|
Sorry, I was not very clear:
I hop into B by calling a function B declares as DllExport, and A sees as DllImport. B has a dll and a lib and A can see them. This has always worked OK when I called it "fresh" every time.
B's internal objects - static instances of B's classes - seem to be null when I go into B using the void* - I get the buffer overrun when I call functions of an internal object. (I am not allowed to use dynamic allocation "because the code is safety critical". This makes things very hard.) When I call B I import the stuff like this:
DllExport int BDoWork(
struct BigDataBlock1 *pBigDataBlock1,
struct BigDataBlock2 *pBigDataBlock2,
void* pB)
I turn the void* back into a proper pointer like this:
BWrapper* pmyB = (BWrapper*)pB;
and it works OK, I can import data along with the pointer, and it seems to be alright, I can copy the data into B's internal structures. I use ASSERT when copying.
B was written by myself. Respectable code always has a few bugs. I am sure there are still a few in there. What should I be looking for? It imports and handles very large amounts of data; I already had to cut the data into slices to avoid overflowing buffers on the dll call. I made it a dll so I could go into B with the debugger when debugging A. (Visual Studio is cool; it can even hop into Ada dlls, can you imagine?)
You helped me a lot by saying void* should work the way I use it. Now I suppose the bug is inside B so I can concentrate there.
-------------
Ave computer! Hackitura te salutat!
(I just made this up. Just to show you can hack Latin as well as C++.)
|
|
|
|
|
Your casting of the void* looks correct and, as you say, allows you to process things as you would expect.
RedSonja wrote: Now I suppose the bug is inside B so I can concentrate there.
I think you probably answered your own question, something inside B may not be behaving correctly. Looks like some long hours stepping through the debugger - good luck.
|
|
|
|
|
Found it!
Some external dll (G) I was using in B had an interface using CString. Since I am not allowed to use MFC, I redefined these to be string. I don't actually use these parts. Anyway, string is not the same as CString and this was causing an access violation, even though it compiled and linked, the rat.
I solved this by taking a local copy of the G.h file of the external dll. In it I put includes so it could see CStrings. This actually makes the exclusion of MFC in my own code redundant, but I can't help that. The G people are not willing to work without MFC (neither was I actually).
G also had some problems in its export functions, which are being repaired. We are pleased to find these bugs now and not after delivery.
-------------
Ave computer! Hackitura te salutat!
(I just made this up. Just to show you can hack Latin as well as C++.)
|
|
|
|
|
Hi all,
I am working on serial port application on VC6 using non overlapped IO.
I used the following time out values.
ReadIntervalTimeout = 1;
ReadTotalTimeoutMultiplier =1;
ReadTotalTimeoutConstant =2;
In XP operating system for these settings my application is working fine.
But when I use these settings in windows 2000, the application does not send and receive properly.
In 2000, if I change the settings to
ReadIntervalTimeout = 0xffffffff;
ReadTotalTimeoutMultiplier =0;
ReadTotalTimeoutConstant =0;
it works properly.But If I use these values, my application receiving thread shows CPU usage much high.
Are the settings for read interval are correct? Please clarify..
Regards,
Sunil Kumar
|
|
|
|
|
sunny_vc wrote: ReadIntervalTimeout = 1;
ReadTotalTimeoutMultiplier =1;
ReadTotalTimeoutConstant =2;
Why such low values?
What is your communication speed?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
My application is communicating at 115200 baud rate speed with an
embedded device.
Regards,
Sunil Kumar
|
|
|
|
|
Is the problem that you receive part of the total string from the external equipement?
Is the comunication an answer and a response, or full duplex?
|
|
|
|
|
Hi All VC++ Programmers,
I am working on a project that is to be migrated from vs-2003 to vs-2008.In my application i have 11 different projects.I am giving all my .lib files into project settings->linker->input->additional dipendencies... But in my project settings->linker->command line i am not getting all the .lib files..i am missing three .lib files....Because of that reason i am getting 362 linking errors,all errors are due to not linking with the missing libraries... the errors are as follows..
fwfipd.lib(fwfpelcp.obj) : error LNK2001: unresolved external symbol "public: virtual class ATL::CStringT<char,class StrTraitMFC_DLL<char,class ATL::ChTraitsCRT<char> > > __thiscall DblTinyInt::getString(void)const " (?getString@DblTinyInt@@UBE?AV?$CStringT@DV?$StrTraitMFC_DLL@DV?$ChTraitsCRT@D@ATL@@@@@ATL@@XZ)
......and many other errors.......
can anybody please give some remedy to my problem?thanks in advance.......
|
|
|
|
|
Vetukuri Raju wrote: can anybody please give some remedy to my problem?
Your linker cannot find the DblTinyInt::getString function. You need to find this library or source and add it to your project.
Best Wishes,
-David Delaune
|
|
|
|
|
Hi actually my application is working in release mode...but not working in debug mode....i have several libraries...in debug mode three libraries are not getting linked...in my command line they are not shown...what to do
|
|
|
|
|
Vetukuri Raju wrote: Hi actually my application is working in release mode...but not working in debug mode
Yes, they have seperate build settings.
Vetukuri Raju wrote: ....i have several libraries...in debug mode three libraries are not getting linked...in my command line they are not shown...what to do
You don't know how to add libraries to your project settings? Are you using a Makefile or the graphical interface? Do you have your library paths setup correctly?
Another way to add link libraries is to add them to source files:
#pragma comment(lib, "Your_Library.lib")
Best Wishes,
-David Delaune
|
|
|
|
|
hi
i am setting my libraries from project settings->linker->input->additional dependencies...here i am putting my all libraries...
and where do i give full library paths?
|
|
|
|
|
Vetukuri Raju wrote: where do i give full library paths?
1.) You can add library paths for an single project solution to:
Project settings->General->Additional Library Directories
2.) If you want these libraries to be globally available to all projects you open in Visual Studio you can add them to:
Tools Menu ->Options->Projects and Solutions->VC++ Directories (choose Library files from combo)
I suspect that you need option 1.
Best Wishes,
-David Delaune
|
|
|
|
|
Hi
In my project some .obj files are not getting linked...
If i put ProjectSettings->Linker->General:Link Library Dependencies and Use Library Dependency Inputs to:YES then the errors are not included with the .lib files(But showing on .obj files corresponding to the respected libraries.).... If i say NO in the option,i am getting same number of errors,but showing errors in the libraries also.... I have tried your options to get the libraries to be linked.but not done... I will be very helpful if give some remedy to this problem...
|
|
|
|
|
Hi how to solve the following error...
CVTRES : fatal error CVT1100: duplicate resource. type:DIALOG, name:PRINTSTATUS, language:0x0409
LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt
It is saying that it is a duplicate resource,but in my .rc file i dont have an id for this dialog.if i am attempting to give any id to this dialog it is giving many other errors....why i am getting this error even though i dont have an id for this perticular dialog...please provide some remedy...
|
|
|
|
|
Vetukuri Raju wrote: It is saying that it is a duplicate resource,but in my .rc file i dont have an id for this dialog.
Make sure that you check all resource files included in your project. In Visual Studio 2008 you need to go to the Resource tab and right click the YourProject.rc folder. Now choose 'Resource Includes' which will show you all of the included resource files. Check them all for a PRINTSTATUS dialog. You can probably ignore all of the Standard MFC Resources[^] as their resource definitions always begin with AFX_...
Best Wishes,
-David Delaune
|
|
|
|
|
HI
Thanks for the reply..I did as you told.I have looked for the resource files..I have my dialog into my project,but my problem is that i dont have any id for that particular PRINTSTATUS dialog in my .rch file.But i am getting the above error...Any code conversion problem?The same code is working successfully in vs-2003.
And when iam ignoring Standard MFC Resources i am getting the errors about menu items saying that unable to find IDR_NEW(one menu item)....etc..
Actually i am ignoring
afxres.rc
please suggest me to solve the perticular LNK error
Thank you
|
|
|
|
|
When a network is connected, a balloon pops up from the system tray saying that the connection has been established and indicating the connection speed.
How can I programmatically get this connection speed for a specific interface? I am constrained to using C and the Windows API.
Thanks in advance.
M.
|
|
|
|
|
mikey_eff wrote: How can I programmatically get this connection speed for a specific interface? I am constrained to using C and the Windows API.
You can use the Performance API (aka, Performance Data Helper) for this. The Object name is Network Interface. The Instance name is machine specific (eg, Intel[R] PRO_100 VE Network Connection - Packet Scheduler Miniport). The Counter name is Current Bandwidth.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Having a bit of trouble. Getting PDH_NO_DATA when calling PdhCollectQueryData. Here is my code:
#define COUNTER "\\Network Interface(Intel(R) 82566DM-2 Gigabit Network Connection - Packet Scheduler Miniport)\\Current Bandwidth"
HQUERY query;
HCOUNTER counter;
PDH_FMT_COUNTERVALUE value;
DWORD counterType;
PDH_STATUS status;
if((status = PdhOpenQuery((LPCSTR)NULL,(DWORD_PTR)NULL,&query)) == ERROR_SUCCESS){
if((status = PdhAddCounter(query,COUNTER,(DWORD_PTR)NULL,&counter)) == ERROR_SUCCESS){
if((status = PdhCollectQueryData(query)) == ERROR_SUCCESS){
if((status = PdhGetFormattedCounterValue(counter,PDH_FMT_DOUBLE|PDH_FMT_NOSCALE,&counterType,&value)) == ERROR_SUCCESS){
printf("Counter = %f\n",value.doubleValue);
}else{
printf("ERROR: PdhGetFormattedCounterValue() failed. Error Code: %X\n",status);
}
}else{
printf("ERROR: PdhCollectQueryData() failed. Error Code: %X\n",status);
}
}else{
printf("ERROR: PdhAddCounter() failed. Error Code: %X\n",status);
}
PdhCloseQuery(query);
}else{
printf("ERROR: PdhOpenQuery() failed. Error Code: %X\n",status);
}
|
|
|
|
|
mikey_eff wrote: #define COUNTER "\\Network Interface(Intel(R) 82566DM-2 Gigabit Network Connection - Packet Scheduler Miniport)\\Current Bandwidth"
You are missing the name of your machine:
#define COUNTER "\\\\machine\\Network Interface(Intel(R) 82566DM-2 Gigabit Network Connection - Packet Scheduler Miniport)\\Current Bandwidth"
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Thanks. That got things working.
Note: I struggled for a bit until I discovered that the name of my adaptor -- "Intel(R) 82566DM-2..." -- was causing me grief because of the "(R)". Had to change the round brackets to square brackets -- "[R]" -- to get it to work.
Mike.
|
|
|
|
|
Hi Mikey,
If you use the IP Helper library[^] then you can do this:
#include "Iphlpapi.h"
#pragma comment(lib, "iphlpapi.lib")
VOID PrintEthernetSpeeds()
{
BYTE *pBuf=NULL;
DWORD dwSize=0;
DWORD dwResult=0;
BOOL bConnected=FALSE;
PMIB_IFTABLE pMIBTable;
CString str;
GetIfTable(NULL,&dwSize,FALSE);
pBuf=new BYTE[dwSize];
pMIBTable=reinterpret_cast<PMIB_IFTABLE>(pBuf);
if(NO_ERROR == GetIfTable(pMIBTable,&dwSize,FALSE))
{
for(UINT i=0; i < pMIBTable->dwNumEntries; ++i)
{
if(MIB_IF_TYPE_ETHERNET == pMIBTable->table[i].dwType)
{
char szBuf[MAX_PATH];
sprintf(szBuf,"%s is %ld\n",pMIBTable->table[i].bDescr,pMIBTable->table[i].dwSpeed);
TRACE(szBuf);
}
}
}
delete []pBuf;
}
Best Wishes,
-David Delaune
|
|
|
|
|
Thanks! Works great. Modified code slightly for ANSI C. See below ...
Mike.
BYTE *pBuf=NULL;
DWORD dwSize=0;
DWORD dwResult=0;
BOOL bConnected=FALSE;
PMIB_IFTABLE pMIBTable;
UINT i;
GetIfTable(NULL,&dwSize,FALSE);
pBuf=(BYTE *)malloc(dwSize);
pMIBTable=(PMIB_IFTABLE)pBuf;
if(NO_ERROR == GetIfTable(pMIBTable,&dwSize,FALSE))
{
for(i=0; i < pMIBTable->dwNumEntries; ++i)
{
if(MIB_IF_TYPE_ETHERNET == pMIBTable->table[i].dwType)
{
printf("%s is %ld\n",pMIBTable->table[i].bDescr,pMIBTable->table[i].dwSpeed);
}
}
}
free(pBuf);
|
|
|
|
|
It's a Win32 FAQ
see on Win32 ng http://tinyurl.com/cmhb5g
(from Windows+Wine source code, net apis...)
|
|
|
|