|
If you know STL, vector would handle your needs.
A C++ programming language novice, but striving to learn
|
|
|
|
|
Thank You so much....
That Was a GREAT Answer.....
|
|
|
|
|
When I went through STL VECTOR....
I found Another one too...
That can be used for the same....
STL MAP
|
|
|
|
|
Read the information in MSDN on the different "containers", ie, vector, list quene(MS?),map and muti-Map. Then you can make an informative decision as to which "container" will suit your needs. Enjoy!!
A C++ programming language novice, but striving to learn
|
|
|
|
|
If you email me directly (larryamillssr@hughes.net) I'll send you some production code showing you how to create a vector, use that vector, save that vector's data and how to retrieve it back and put it into a vector.
A C++ programming language novice, but striving to learn
|
|
|
|
|
It stores data only temporarily
|
|
|
|
|
anna mathew wrote: Other than Files What all Can I Use...
Whether you use a database, an INI file, the registry, or some text file, they are all still files. You have no choice but to use a file. What kind of file is still debatable.
Are you wanting persistent storage, or just an in-memory data structure?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
You can use of text files or use of xml files or pdf files.
|
|
|
|
|
Hi there,
I've been trying a hook notepad using SetWindowsHookEx function and the WH_GETMESSAGE message but to no avail.
Below is my current running code. My code compiles and run, the problem is that the
LRESULT WINAPI GetMsgProc(UINT nCode, WPARAM wParam, LPARAM lParam) function is never called.
Can somebody please help as to why that function is never executed when I start/close notepad?
#define WIN32_LEAN_AND_MEAN // trim the excess fat from Windows
#include <stdlib.h>
#include <crtdbg.h>
#include <windows.h>
#include <windowsx.h>
#include <tchar.h>
#include <stdio.h>
#include <string.h>
#include <locale.h>
#include "Resource.h"
LRESULT WINAPI GetMsgProc(UINT, WPARAM, LPARAM);
BOOL CALLBACK DlgProc(HWND, UINT, WPARAM, LPARAM);
HWND hWndMainDialog;
HHOOK hIISHook;
HINSTANCE hinstDLL;
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
BOOL bOK = FALSE;
hinstDLL = LoadLibrary((LPCTSTR) _T("c:/WINDOWS/system32/notepad.exe"));
hIISHook = SetWindowsHookEx(WH_GETMESSAGE, GetMsgProc, hinstDLL, 0);
bOK = (hIISHook != NULL);
if (bOK)
{
MessageBox(NULL,_T("Low Level hook installed properly"), _T("Information"), MB_OK);
}else
{
UnhookWindowsHookEx(hIISHook);
MessageBox(NULL,_T("Error Installing Hook"), _T("Information"), MB_OK | MB_ICONSTOP);
}
DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG_IIS), NULL, DlgProc);
UnhookWindowsHookEx(hIISHook);
_CrtDumpMemoryLeaks();
return 0;
}
LRESULT WINAPI GetMsgProc(UINT nCode, WPARAM wParam, LPARAM lParam)
{
PMSG msg;
msg = (PMSG)lParam;
return CallNextHookEx(hIISHook, nCode, wParam, lParam);
}
BOOL CALLBACK DlgProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
BOOL b;
switch(Msg)
{
case WM_INITDIALOG:
hWndMainDialog = hWnd;
return TRUE;
case WM_COMMAND:
switch(HIWORD(wParam))
{
case BN_CLICKED:
switch(LOWORD(wParam))
{
case IDC_BTN_PROCESS:
b = FALSE;
if(!b)
{
MessageBox(NULL,_T("Button has been clicked"), _T("Information"), MB_OK | MB_ICONSTOP);
return;
}
break;
}
break;
}
return TRUE;
case WM_CLOSE:
PostQuitMessage(0);
return TRUE;
case WM_DESTROY:
PostQuitMessage(0);
return TRUE;
}
return FALSE;
}
</locale.h></string.h></stdio.h></tchar.h></windowsx.h></windows.h></crtdbg.h></stdlib.h>
|
|
|
|
|
u need to check the recvd messages of notepad in ur GetMsgProc().
and post a message to ur app when u recv the desired message.
|
|
|
|
|
use WH_CALLWNDPROC type instead of WH_GETMESSAGE
|
|
|
|
|
i have 6 COM dlls that are shared between 4 different versions of our product, more than one version can be installed at any one time. so in which directory do I put them?
is C:\Documents and Settings\All Users\Application Data\<company-name> a good one for putting dlls?
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
If they are all the same, and are COM DLLs, they can reside anywhere. If each version of the app requires slightly different and incompatable versions of the DLLs, which means someone did not version the COM interfaces correctly and broke the "COM Contract", I would keep them in each app's install directory and have a bootstrapper register them when the app starts.
If the DLLs' interfaces are versioned correctly, you just have to keep the most recent version somewhere and register it.
If you go the APPDATA route, be sure to select a suitable subdirectory.
Peace!
-=- James Please rate this message - let me know if I helped or not!<hr></hr> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Thanks for the helpful answer
I will probably put the files in "C:\Documents and Settings\All Users\Application Data\<company name="">\". The required dll versions are the same - the files in the different versions are exact duplicates.
Anyway, my problem was with the registry - because we have a standard and 'pro' version, if user installs standard version, then pro, then uninstalls pro, standard will stop working. Standard has the dlls in its own directory in Program Files, but pro has overwritten the registry entries to point to its dlls, which are now gone. So I'm going have a single directory for these COM dlls to solve the problem.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
sashoalm wrote: is C:\Documents and Settings\All Users\Application Data\ a good one for putting dlls?
Sure, why not?
But it's a strong recommendation that you create a folder below that path with your company name and place the files in that folder.
However, this only takes care of the issues regarding how to access those shared files and where to put them and since they are COM servers it doesn't matter where they're located.
You also have to consider how they will be installed and un-installed and whether or not you will have an installation wizard at your aid such as Wise or InstallShield.
To be able to know when to unregister the COM servers and remove those files, you should make DWORD-entries in the registry below the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SharedDlls key where the value reflects the reference count. This means that the DWORD value tells how many installed applications will make use of the shared file. When you install you increase that number and consequently you decrease the value when you un-install. When the value reaches zero you unregister the COM server with RegSvr32, or similar, and remove the file and the registry entry.
This can be done automatically with a wizard, but if you're not using one you can do this by yourself.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Hi all,
Can someone explain what's the difference between the followings.
int freeLib = FreeLibrary(m_hwnd_Lib);
int freeLib = ::FreeLibrary(m_hwnd_Lib);
Thanks
I appreciate your help all the time...
CodingLover
|
|
|
|
|
int i=0;
{
int i=1;
std::cout<<i;
std::cout<<::i;
}
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Rajesh R Subramanian wrote: int i=0;{
int i=1;
you'd better say that the opening bracket is the start of the main() function. otherwise, that code could be anywhere, even nested in a function body, and then, your outter i would not be in the global scope, then, unreachable using the global scope operator :: ...
|
|
|
|
|
The :: operator is called the scope operator.
You use it to inform the compiler in what scope an identifier is declared, i.e what namespace and/or class.
Putting the scope operator in front of an identifier means that you explicitly refer to an identifier in the global namespace, thus even if an identifier in the current namespace or class is declared with the same name, the identifier declared in the global namespace is used.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Fine, that's the basis idea I have.
But one thing I've confused, in windows API some cases it's use and some cases it's not. Why is that?
I appreciate your help all the time...
CodingLover
|
|
|
|
|
CodingLover wrote: But one thing I've confused, in windows API some cases it's use and some cases it's not.
You have to clarify that.
When referring to the "windows API", it usually means functions that resides in e.g. Kernel32.dll that can be called from any language such as C, C++, VB, C#, Java and so on.
The scope operator is C++ specific so as I understand it your question doesn't make sense.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
It prevents a same-name and same-signature class member from being called by accident.
For example, if you are working in a class that has a member SetWindowText( HWND, LPCTSTR ) , but you want to call the Win32 (or global) version of it, you would use ::SetWindowText( hWnd, _T( "Your Text" ); . Otherwise, you would call the class' version of the function.
Calling API functions like that also protects you from future changes - if you have code in a class that calls SetWindowText(...) and in the future someone adds a member function to the class (or its base) with the same signature and recompiles your code, your older code would start calling the newer method. This may or may not be what you want, so you can "future-proof" your code by using the global namespace operator.
Peace!
-=- James Please rate this message - let me know if I helped or not!<hr></hr> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
You're probably talking about MFC? For example, if you call MessageBox, that would call the MessageBox function provided by MFC, whereas ::MessageBox would call the global version (WIN API).
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
CodingLover wrote: Why is that?
no need to use it when there is no ambiguity. unless you want to make the code perfectly readable.
If the compiler has many definitions of the same identifier, then if you don't use the scope operator, the identifier in the current scope will be used. if not found there, then it will search in the namespaces declared to be currently in use (using namespace directive).
To tell the compiler that you want to use the global scope identifier, then you have to prepend it with :: ...
|
|
|
|
|
CodingLover wrote: Can someone explain what's the difference between the followings.
int freeLib = FreeLibrary(m_hwnd_Lib);
int freeLib = ::FreeLibrary(m_hwnd_Lib);
Yes: I see two colons in the latter statement, missing in the former one.
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]
|
|
|
|
|