|
I was under the impression that you usually use extern "C" when you are trying to access code in other languages from C++..but I have also noticed that extern "C" is used sometimes within C++ to call various functions especially in a lot of DLLs..
For instance, the other day I came across a piece of code where you had a dialog resource in one separate DLL project and an MFC Doc/View exe in another project. Now, one of the dialogs opened by the the MFC Doc/View was in the resource DLL and in order to establish a link between these two, the following task was done:
there was a extern "C" function which was created in a separate C++ within the MFC Doc/View project. Inside of the function, there was a call made to certain method in certain class within this project. Also, in the header file for that class, this function was defined as extern "C".
Next, an event handler in the resource DLL was built and it would make a reference to this extern "C" function.
|
|
|
|
|
Is your question what is extern "C" for?
All that extern "C" does, is instructs the compiler to not include namemangling in the symbols that it creates for that function, variable or whatever. This will allow dlls from other languages to more easily access the functions.
Normally the compiler adds decorations to the names in order to allow function overloading in C++. IF you trun off name mangling, then you will not be able to over load your functions. That is the drawback.
Good Luck
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
hi,
look at this:
"ULONG PacketGetAdapterNames(PTSTR pStr, PULONG BufferSize)
Usually, this is the first function that should be used to communicate with the driver. It returns the names of the adapters installed on the system in the user allocated buffer pStr. After the names of the adapters, pStr contains a string that describes each of them."
suppose that in my machine I'he several adapters, hwo I use pStr to get those names?
|
|
|
|
|
My guess would be:
<br />
TCHAR caBuffer[ 4096 + 1 ];<br />
DWORD dwBufSize = 4096;<br />
<br />
PacketGetAdapterNames( caBuffer, &dwBufSize );<br />
caBuffer[ 4096 ] = _T( '\0' );<br />
Peace!
-=- James.
"Fat people are hard to kidnap."
(Try Check Favorites Sometime!)
|
|
|
|
|
1. How to programatically (VC++) find out the network default settings on a machine, if it's DialUp or LAN
2. How to find out if the connection is "ON", i.e the computer is connected ? That is either the DIalUp is on, or the LAN is active???
many thanks..
Hawk
![Frown | :(](https://www.codeproject.com/script/Forums/Images/smiley_frown.gif)
|
|
|
|
|
1. Lee Hamel's article Retrieving NIC information using SNMP queries gives you the means to retrieve the list of IP interfaces installed on the machine. Please note interfaces can coexist both for LAN and Dial-up.
2. For LAN interfaces, there's no easy way to know if the machine is actually connected (meaning by that that the cable is plugged in.) There's a way to do it in Win2000, but the thing is messy. As for Dial-up interfaces, simply check whether the IP address is valid: when not connected, it is 0.0.0.0.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
many thanks, I'll try it out... for the LAN I thought using this statement will suffice:
if (!AfxSocketInit())
{
// some code ...
}
since all I care is to check if this can pass if the LAN is "on"... but in case of a modem that was mysterious to me since I don't want to invoke a DialUp connection if the connection isn't already "on", by using the above statement...
and this is why I wanted to check out some explicit way to find out what is on and what isn't...
thanks a lot.
Hawk![Big Grin | :-D](https://www.codeproject.com/script/Forums/Images/smiley_biggrin.gif)
|
|
|
|
|
RasEnumConnections() could help to enumerate active connections. ![Rose | [Rose]](https://codeproject.global.ssl.fastly.net/script/Forums/Images/rose.gif)
|
|
|
|
|
the Cyber Hawk wrote:
How to find out if the connection is "ON", i.e the computer is connected ? That is either the DIalUp is on, or the LAN is active???
Try InetIsOffline(...)
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
Nish - Native CPian wrote:
Try InetIsOffline(...)
Ah great, I have to test that.
Some older articles suggested to resolve localhost (name->IP), then check if it's different to the loopback (127.0.0.1). InetIsOffline() looks more elegant. ![Smile | :)](https://codeproject.global.ssl.fastly.net/script/Forums/Images/smiley_smile.gif)
|
|
|
|
|
I did inlclude <intshcut.h>, compiled OK but couldn't link with the following error "error LNK2001: unresolved external symbol __imp__InetIsOffline@4" ...
those are my includes:
#include <afxwin.h>
#include <afxext.h> // MFC extensions
#include <afxtempl.h> // MFC template classes
#include <afxsock.h> // MFC Sockets
#include <afxdisp.h> // Required by afxpriv.h
#include <afxpriv.h> // to get access to the T2A macro
#include <intshcut.h>
I would like to #include instead of #import; damn linker errors...I'll try to fix it myself, but if you have any thought why it won't link I'd appretiate it... regards..
H.![Cry | :((](https://codeproject.global.ssl.fastly.net/script/Forums/Images/smiley_cry.gif)
|
|
|
|
|
You must add url.lib to the list of link modules
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
Many thanks, it worked... coool !!!!!![Big Grin | :-D](https://codeproject.global.ssl.fastly.net/script/Forums/Images/smiley_biggrin.gif)
|
|
|
|
|
May I change the caption of the Property Page before adding him to the Property Sheet?
If yes, then how?
Best regards,
Eugene Pustovoyt
|
|
|
|
|
Yes, you can. Set your new title to m_psp.pszTitle, and add flag PSP_USETITLE to m_psp.dwFlags.
Martin
|
|
|
|
|
Thank you very much!
That's ok.
Best regards,
Eugene Pustovoyt
|
|
|
|
|
Hi, everyone
How can I connect to a DB2 database that resides on an AS400 machine using Visual C++6.0?
Since I am very new to VC++, I have a very simple question. For me to implement the above functionality, should I use general ODBC or Microsoft ADO stuff? What are the advantages and disadvantages for these two?
Does anyone have any code example to help to go through this? Any help would be greatly appreciated.
Thanks in advance.;)
|
|
|
|
|
Lots of code examples in MSDN. Also good analysis of the different db access methods.
Good luck,
Bill
|
|
|
|
|
Could you please give me some links? I really appreciate it. or could you please tell me what keyword should I search for?;)
|
|
|
|
|
msdn.microsoft.com
search for ODBC
http://search.microsoft.com/default.asp?qu=odbc&boolean=ALL&nq=NEW&so=RECCNT&p=1&ig=01&ig=02&ig=03&ig=04&ig=05&ig=06&i=00&i=01&i=02&i=03&i=04&i=05&i=06&i=07&i=08&i=09&i=10&i=11&i=12&i=13&i=14&i=15&i=16&i=17&i=18&i=19&i=20&i=21&i=22&i=23&i=24&i=25&i=26&i=27&i=28&i=29&i=30&i=31&i=32&i=33&i=34&i=35&i=36&i=37&i=38&i=39&i=40&i=41&i=42&i=43&i=44&i=45&i=46&i=47&i=48&i=49&i=50&i=51&siteid=us/dev
search for ADO
http://search.microsoft.com/default.asp?qu=ado&boolean=ALL&nq=NEW&so=RECCNT&p=1&ig=01&ig=02&ig=03&ig=04&ig=05&ig=06&i=00&i=01&i=02&i=03&i=04&i=05&i=06&i=07&i=08&i=09&i=10&i=11&i=12&i=13&i=14&i=15&i=16&i=17&i=18&i=19&i=20&i=21&i=22&i=23&i=24&i=25&i=26&i=27&i=28&i=29&i=30&i=31&i=32&i=33&i=34&i=35&i=36&i=37&i=38&i=39&i=40&i=41&i=42&i=43&i=44&i=45&i=46&i=47&i=48&i=49&i=50&i=51&siteid=us/dev
search for ODBC ADO
http://207.46.197.63/default.asp?qu=ado+odbc&boolean=ALL&nq=NEW&so=RECCNT&p=1&ig=01&ig=02&ig=03&ig=04&ig=05&ig=06&i=00&i=01&i=02&i=03&i=04&i=05&i=06&i=07&i=08&i=09&i=10&i=11&i=12&i=13&i=14&i=15&i=16&i=17&i=18&i=19&i=20&i=21&i=22&i=23&i=24&i=25&i=26&i=27&i=28&i=29&i=30&i=31&i=32&i=33&i=34&i=35&i=36&i=37&i=38&i=39&i=40&i=41&i=42&i=43&i=44&i=45&i=46&i=47&i=48&i=49&i=50&i=51&siteid=us/dev
Many articles on Code Guru
http://codeguru.com/mfc_database/index.shtml
and here on Code project
http://codeproject.com/database/
You will serve yourself well if you develop a skill for searching the internet for answers to these kinds of question. You will get answers much faster and better with your own searches.
One of the best searches for obscure stuff, is Google. Just type in things like class names, error messages or what ever else is confounding you at the moment.
searching google for ADO ODBC
http://www.google.com/custom?q=ado+odbc&cof=T%3Ablack%3BLW%3A282%3BL%3Ahttp%3A%2F%2Fwww.refdesk.com%2Frd.gif%3BLH%3A94%3BBGC%3Awhite%3BAH%3Acenter%3BAWFID%3A6332576430c078b2%3B
Good luck,
Bill
|
|
|
|
|
Shayna wrote:
Does anyone have any code example to help to go through this? You can download the "Personal Developer" edition of IBM DB2 for free here, it includes all the necessary documentation and code samples. See also IBM's DB2 pages.
|
|
|
|
|
How could I test the existence of a file on a network drive ASynchronously?
I used _access() function. But, that is a synchronous one; won't return immediately for invalid file paths.
![Confused | :confused:](https://codeproject.global.ssl.fastly.net/script/Forums/Images/smiley_confused.gif)
|
|
|
|
|
Go back to old-school
FILE *Stream;
Stream = fopen( "filename", "r" );
if ( Stream == NULL )
{
// That file or path doesn't exist
}
else
{
fclose( Stream );
};
Doug Joseph (Engineering Guy)
|
|
|
|
|
Joe: Thanks for your response.
But what I need is Asynchronous 'kind' of function to test a file existence.
I have the following situation:
Testing existence for \\Serv1\Vol1\Dir1\File1 is finished in few milli seconds if the server 'Serv1' is up and running.
But, if somebody is shutting down the Serv1 and my program tests for the existence of a file on Serv1 at the same time, it takes huge time for the 'check existence' code to return.
Under such situations, I wonder, if there is a kind of 'Asynchronous file existence checking' code which would just return immediately and fire a 'kind' of 'done' event later!!
|
|
|
|
|
Perhaps, you might want to try to ping the server, before checking for the file existance.
Ping's should be realtively quick, especially if you set an artificial timeout on it.
-Doug
Doug Joseph (Engineering Guy)
|
|
|
|