|
Hello people,
See this code:
#ifdef DLLTEST_EXPORTS
#define DLLTEST_API __declspec(dllexport)
#else
#define DLLTEST_API __declspec(dllimport)
#endif
//This class is exported from the dlltest.dll
class DLLTEST_API myclass {
public:
vector <myclass*> v;
myclass(void);
// TODO: add your methods here.
};
Every time I try to export classes (see example above) that use stl classes (e.g. vector) from DLL I get the following warning:
warning C4251: 'v' : class 'std::vector<class myclass="" *,class="" std::allocator<class="" ,="" *=""> >' needs to have dll-interface to be used by clients of class ',myclass'
Any Ideas to solve this?
|
|
|
|
|
I'm not sure, but it looks to me as though the problem is that your class inherits from a parameterized class without using templates. Either
template <class Ty_, class A_ = std::allocator<Ty_> > class DLLTEST_API myclass {
public:
std::vector<Ty_, A_> v;
...
};
or
class DLLTEST_API myclass {
public:
std::vector<char> v;
...
};
should work for you.
In the former case, you may also get into some trouble if you do not define specific instantiations of your generic class, since the way templates are handled in VC++ does not allow separate compilation of the bodies of template functions and class methods, so you can't hide the implementation details of generic classes in a .cpp file that goes into a DLL---the implementation must be present in the header file.
|
|
|
|
|
Read the article of Joseph M. Newcomer "Time is the Simplest Thing..." on this site: http://www.codeproject.com/system/simpletime.asp
|
|
|
|
|
Can any body help me how to achieve serialization in controls.Like suppose if check a checkbox it displays a rectangle in the view.it stays for till the application is closed.While once again if i open the application...how to keep the check mark remain as it is.....urgent?
|
|
|
|
|
Not sure this is what you are looking for, but it may be useful.
I'm assuming you have an MFC app here.
For settings like this, maybe the registry is a better choice than serializing to file. Standard practise is to have code in your InitInstance to get the settings, and code in Exit Instance to save them.
For example in InitInstance, I have code that does something like this to let the user know what directories they're working with:
SetRegistryKey(_T("My Application"));
LoadStdProfileSettings(16);
m_dlgOptions.m_strSlideDir = GetProfileString(_T("Settings"), _T("Slide directory"));
m_dlgOptions.m_strTaskDir = GetProfileString(_T("Settings"), _T("Task directory"));
m_dlgOptions.m_strResultsDir = GetProfileString(_T("Settings"), _T("Results directory"));
m_dlgOptions.m_nLastTaskID = GetProfileInt(_T("Settings"), _T("Last used task ID"),1000);
m_dlgOptions.m_nLastUserID = GetProfileInt(_T("Settings"), _T("Last used user ID"),100);
Then, since the user can change these, ExitInstance has mirror code to write them back:
WriteProfileString(_T("Settings"), _T("Slide directory"),m_dlgOptions.m_strSlideDir);
WriteProfileString(_T("Settings"), _T("Task directory"),m_dlgOptions.m_strTaskDir);
WriteProfileString(_T("Settings"), _T("Results directory"),m_dlgOptions.m_strResultsDir);
WriteProfileInt(_T("Settings"), _T("Last used task ID"),m_dlgOptions.m_nLastTaskID);
WriteProfileInt(_T("Settings"), _T("Last used user ID"),m_dlgOptions.m_nLastUserID);
You'll probably want to write a 1 or 0 to some key based on the checkbox setting, and if the dialog is not a member of the App class you'll need to update the App class with the data.
If you are saving lots and lots of data though, this might not be the best way to go.
One added advantage is that these settings come from HKEY_CURRENT_USER, so when another user logs on they get their own settings.
Actually, this is not serialazation of controls so much as preservation of the state they represent.
|
|
|
|
|
I am trying to connect to an MS Exchange Server, get all of the registered e-mail addresses and then cleanly exit. I have tried to do this with MAPI but so far been unsuccessful. ANy Ideas?
alan rencher
|
|
|
|
|
Hi , I was wondering how a callback timer procedure works ? It will be best if anyone can provide me with a source code to illustrate as an example. Thanks alot.
|
|
|
|
|
How can i get the Window-Name of a process, if i know the PID?
Or is there a way to check, if this process is running, if i still now the PID!
Thank's
|
|
|
|
|
Dr Norm says:
Enumerate all the windows on the system, this may sound an expensive process, but its quite fast.
Regards
Norm
// In your header...
struct EnumTest
{
DWORD dwProcID;
HWND hWnd;
};
... somewhere in your code
EnumTest t;
ZeroMemory(&t, sizeof(t));
t.dwProcID = yourProcID;
EnumWindows(EnumWindowsProc,(LPARAM) &t);
// If we found it
if (t.hWnd != 0)
{
char szBuffer[256];
GetWindowText(t.hWnd, szBuffer, sizeof(szBuffer));
}
BOOL CALLBACK CRemote::EnumWindowsProc(HWND hWnd, LPARAM lParam)
{
DWORD dwID = 0;
if (GetWindowThreadProcessId(hWnd,&dwID))
{
EnumTest *p = (EnumTest*) lParam;
DWORD dwResult;
if (dwID == p->dwProcID)
{
pProc->bHung = TRUE;
return FALSE;
}
}
return TRUE;
}
|
|
|
|
|
My first question to you would be "Why?"
If you have the PID, that suggests that you spawned this process. What are you trying to do? Find out when a process has ended? If that's the case, you need only wait on the process handle in a background thread.
|
|
|
|
|
If you were writing a spy program that monitors some aspect of the program, the obvious thing to do is to present the user with a list of process names, rather than a list of PIDs. Also if you were writing a task manager like program or a program to list the DLLs of a given process.
Plenty of reasons.
Stephen Kellett.
|
|
|
|
|
Yes, there are plenty of reasons. I want to know *HIS* reason, since there is probably some other way to accomplish what he wants.
|
|
|
|
|
Hi
First, thank you for your help, it was helpful.
I like to program an NT-Service, which starts a DOS-program. So if the program has been terminated, the service has to shut down too.
So I just like to find out when a process has ended or to find out the status of this process.
Peace
|
|
|
|
|
I don't know if any of you have ever noticed this... but assume that you want to create a popup menu that appears when you right in a tree control.
If you are using the single selection style (and perhaps in other cases as well) if you right click an item that does not have the selection/focus... then handle the NM_RCLICK notification and display a popup menu during it... the selection shifts BACK to the original item that was highlighted... instead of the item that was right clicked.
I assume that I am missing some simple trick to avoid this. I'm getting frustrated here.
Thanks for any assistance anyone can provide!!!
|
|
|
|
|
Funnily enough I just solved this one yesterday.
Hope this helps
Norm
void CLeftView::OnRclick(NMHDR* pNMHDR, LRESULT* pResult)
{
// Find client cursor pos...
CPoint point;
GetCursorPos(&point);
ScreenToClient(&point);
// Setup hit-code for treeitem
UINT dwItem = TVHT_ONITEM;
HTREEITEM hItem = GetTreeCtrl().HitTest(point,&dwItem);
if (hItem == NULL)
return;
// Now select the item - for real
GetTreeCtrl().Select(hItem,TVGN_CARET);
// ... some other code...
}
|
|
|
|
|
Hi All,
Q1: Any one have (simple) sample code on establishing a TCP Connection???
Q2: I need to capture some TCP/UDP Packet data (to see what a client sends to a virus server when a virus if found). I have a sniffer and the data is coming out unreadable (portions of it)??
Project Explination: I need to find out what data is being sent to a virus server which reports the virus. Once I have that, create a program that will test the reporting on all of the Virus Servers (50+). Basically send TCP/UDP message to each Server...who ever doesn't report the virus is having reporting problems.
Help is much appreciated
Thanks in advance,
Dan
|
|
|
|
|
Ok - so basically your prog is a kind of 'yes I'm here' type thing that you can run periodically to see that all hands are reporting.
The real killer would be if the packets are encrypted by the reporting program - then your only hope is binary dup and pray you fool the server.
But the first problem is getting the data.
You will probably be looking for UDP packets arriving from the clients on the server. (Just a guess). Next, there will probably be a port number you can identify (the servers listen or 'recievefrom' sockets local port).
Once you have that info, you can filter the packets accordingly and see whats being sent.
Just a suggestion though - except for the fact that you'll see the virus server respond, all your testing is that the wire's not cut. You could probably write simple clients on both ends to test that. (yes even a one socket client can do some 'listening' if you don't overload it).
Hmmm... surely this has been done before... hmmm... need coffee... hmmm... where's the 'sleepy' emoticon...
|
|
|
|
|
Thanks for the info Tim. I have created a server component that will monitor a port (139 - TCP) used by the reporting Server. After I perform some tests, I'll let you know hao it turns out. Seeing that this is not anything that my firm will not have a problem with me posting the code for others to use that need to perform simular tests.
Thanks in advance,
Dan
|
|
|
|
|
Has anyone capture the appearance of mouse on windows 98?
|
|
|
|
|
Do you mean what the cursor is set to ? GetCursor will return the current cursor for you. If you mean where the mouse appears, then GetCursorPos will return the mouse pos, and there are VK_ definitions for the mouse buttons, so you can get them as you would any other key.
Christian
The content of this post is not necessarily the opinion of my yadda yadda yadda.
To understand recursion, we must first understand recursion.
|
|
|
|
|
I meant that capturing of mouse position and what I need is to record the position of mouse position into a file . If you have any source code on mouse capture , can you show me so that I can learn more effectively ?
|
|
|
|
|
You want a file that logs the mouse position ? This would be very easy to do, but how big do you want the file to be ? How often do you want to know the mouse position ? Why ?
Christian
The content of this post is not necessarily the opinion of my yadda yadda yadda.
To understand recursion, we must first understand recursion.
|
|
|
|
|
I am suppose to capture the mouse position every 30 ms but I read about the timer and the fastest i can capture it at every 50 ms interval. I have not read about file and so do not have any idea on how big the file . So what do you suggest?
|
|
|
|
|
Whoever told you that is wrong - the smallest interval you can set the timer to is one millisecond. Look up CFile to create the file, the point of my question was if you did it in OnMouseMove you'd have a massive file. As it is you'll get a reasonable size file pretty quickly. You'll use GetCursorPos to get the mouse position in OnTimer.
Christian
The content of this post is not necessarily the opinion of my yadda yadda yadda.
To understand recursion, we must first understand recursion.
|
|
|
|
|
What if I store the position of mouse in a file , then later on I want to restore the current mouse position to that of the position stored earlier in the file?
|
|
|
|