|
kilowatt wrote:
I think that there may be a CStringList class that you can use that is predefined in MFC.
Now I use this one,But I get error in the RETURN statement of my function:
error C2558: class 'CStringList' : no copy constructor available or copy constructor is declared 'explicit'
Any Suggestion?
Thanks
Mazy
"The more I search, the more my need
For you,
The more I bless, the more I bleed
For you."The Outlaw Torn-Metallica
|
|
|
|
|
return "CStringList *" or "CStringList &"
-c
The ants are my friends. They're blowing in the wind.
|
|
|
|
|
Thanks
Mazy
"The more I search, the more my need
For you,
The more I bless, the more I bleed
For you."The Outlaw Torn-Metallica
|
|
|
|
|
If you are trying to return a CList as opposed to a CList*, you're going to have trouble. You have two choices here:
1. Send in the address of or a reference to the CList like so:
BOOL FindFile( LPCTSTR directorypath, CListCList<TYPE_LIST>* list )
{
}
CList<TYPE_LIST> myList;
if( !FindFile( "bob.txt", &myList ) )
{
}
or
BOOL FindFile( LPCTSTR directorypath, CList<TYPE_LIST>& list )
{
}
CList<TYPE_LIST> myList;
if( !FindFile( "bob.txt", myList ) )
{
}
2. The other way you can do this is by creating your CList with new inside the function like this:
CListCList<TYPE_LIST>* FindFile( LPCTSTR directorypath )
{
CListCList<TYPE_LIST>* myList = new CListCList<TYPE_LIST>();
.
.
.
return myList;
}
CList<TYPE_LIST>* list = FindFile( "bob.txt" );
.
.
.
list->RemoveAll();
delete list;
You must call delete on the list if you do it this last way or you'll have a memory leak.
Hope this helps.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
Thank you very much Matt.It is very helpful.
Mazy
"The more I search, the more my need
For you,
The more I bless, the more I bleed
For you."The Outlaw Torn-Metallica
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
|
RasEnumConnections() could help to enumerate active connections.
|
|
|
|
|
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.
|
|
|
|
|
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.
|
|
|
|
|
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 !!!!!
|
|
|
|
|
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
|
|
|
|