|
I am curious what people use to secure the shared memory that is commonly used as an IPC mechanism between two processes. Any thougts and prototypes?
thanks!
|
|
|
|
|
Lambu Jindu wrote: I am curious what people use to secure the shared memory that is commonly used as an IPC mechanism between two processes. Any thougts and prototypes?
For Securing People Generally use Encrypted text for sending data! or SSL ( with sockets)
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
I've created an application with runs as a plugin for Microstation.
My application is a DLL whose functions are called by Microstation in a specific lanaguage.
if my function launch a dialog box like this
definition:
extern "C" __declspec(dllexport) BOOL fooSystem_showAboutBox();
implementation:
BOOL fooSystem_showAboutBox()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
try
{
theApp.showAboutBox();
}
catch(...)
{
return FALSE;
}
return TRUE;
}
//in foo.cpp
void CFooApp::showAboutBox()
{
CAboutDialog dlgAbout;
dlgAbout.DoModal();
}
then, the "about" dialog is not able to intercept any messages like WM_TIMER, and the function PreTranslateMessage is never reached. This problem is also valid for theApp.
There isn't any other classes which may intercept messages before my function (maybe except one from MFC hierarchy) or implementing the virtual function PreTranslateMessage.
I really don't understand this.
Have you any idea about this issue ?
Thanks.
Firejano
-- modified at 11:42 Thursday 27th October, 2005
|
|
|
|
|
Is there a hash string function that preserves the capability to compare two strings just by comparing their respective hash values ?
Currently, I have to perform a full Str.Compare("other string") in order to sort them. I had also calculated their hash value, but the sorting (Quick Sort, Bubble Sort, whatever...) fails using the hash value. The hash value is mostly random, especially on long strings.
Comparing the hash values (int) would have been quite faster, I have to perform the quickest sort possible on text files larger than 100 MB ! So please don't come with CString as a solution. It works, but asks hours to do the job. CString is perfect to manipulate UI strings, but bad for heavy duty purposes...
So, to sum up, it there a good hash function that will allow :
"Minus string" < "Plus string"
HASH("Minus string") < HASH("Plus string")
Kochise
In Code we trust !
|
|
|
|
|
Kochise wrote: it there a good hash function that will allow ...
my gut reaction is No. the amount of information required to accurately compare two strings is all of the information in each string. but hashes for arbitrary input grind the information in the source data down into a package that's large enough that two different input strings will have a small (but still non-zero) chance of generating the same hash, but small enough to be passed around and used quickly.
but if you have less data than you started with and the possibilty that two source values will produce the same hash, then there's no way to go from the hash back to the source value, and so there's no way to guarantee an accurate sort using just the hash.
that's not to say hash values can't play a role in sorting, of course (they do, and there's a lot of info in Google about this very large topic), just that you can't generate a small numeric reversible hash for arbitrary character strings.
Cleek | Image Toolkits | Thumbnail maker
-- modified at 16:29 Thursday 27th October, 2005
|
|
|
|
|
Nadanada, I'm not willing to 'compress' a string in an integer, and restore the string from the integer afterward. What I just want is to help my sorting routines by feeding it with fixed size integer the CPU could handle very easily, not variable length strings...
Currently, I'm feeding a custom string tree. All strings are stacked as-is, and I used the HASH value as node's key. Even if they are mostly 'random', strings are inserted 'as-is' from their hash value. It works. I can even search for a particular string, it's hash value is found in the tree.
The problem occurs when I'm trying to sort the tree, or at least walk it in a ascendant or descendant way. What I get is hash values from the minus one to the maximum one. But their corresponding string is non-sense, they don't follow the ascending or descending order I'm trying to get.
Yeap, I found some pages on Google about hash functions :
http://www.partow.net/programming/hashfunctions/
http://www.isthe.com/chongo/tech/comp/fnv/
http://www.cs.rice.edu/~scrosby/hash/
But none helped me in what I was trying to get. I can accept a little level of collision, because I know and control the input. And even if I get the same hash match, I can always control the two strings with a good old compare. At least I saved the whole tree walking which was processed in hash integer comparaison.
So thanks at least to having helped me to loose focus on the 'hash trick', as this won't evolve in a success. I will try another method to sort out my strings using an integer.
Kochise
In Code we trust !
-- modified at 3:18 Friday 28th October, 2005
|
|
|
|
|
Kochise wrote: But their corresponding string is non-sense, they don't follow the ascending or descending order I'm trying to get.
then just take the first four characters and stuff them into a long:
long hash = (str[0] << 24) | (str[1] << 16) | (str[2] << 8) | (str[3]);
that will allow you to very quickly compare the first four characters of the strings.
you'll get a collission any time the first four characters of the two strings match.
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
I already tried this way, but I have many strings that starts with the same characters. So I'm trying to create a kinda dictionary of the whole strings, and find the good one the most quickly possible through the use of integer. I could have used tries as well, I think I'm going to test this.
The following code match "TEST" and "TEST TEST" as being the same string, even if I stuff things of 16 characters. Maybe I'm wrong...
void CStringTree::_EncodeString
( sMSP& o_rsStringPointer
, const char* i_panStringBuffer
, int i_nStringSize
)
{
double l_nShifter = 79228162514264337593543950336.0;
int l_nLoop = 16;
int l_nSize;
unsigned char l_nChar;
if
(
(i_nStringSize < 0)
|| (i_nStringSize > 16)
)
{
l_nSize = 16;
}
else
{
l_nSize = i_nStringSize;
}
o_rsStringPointer.nHashRaw = 0.0;
o_rsStringPointer.nHashCase = 0.0;
o_rsStringPointer.nHashNoCase = 0.0;
while(l_nLoop > 0)
{
l_nChar = *i_panStringBuffer;
if
(
(l_nSize == 0)
|| (l_nChar == 0)
)
{
o_rsStringPointer.nHashRaw += ' ' * l_nShifter;
o_rsStringPointer.nHashCase += ' ' * l_nShifter;
o_rsStringPointer.nHashNoCase += ' ' * l_nShifter;
}
else
{
o_rsStringPointer.nHashRaw += l_nChar * l_nShifter;
o_rsStringPointer.nHashCase += g_panNormal[l_nChar] * l_nShifter;
o_rsStringPointer.nHashNoCase += g_panNoCase[l_nChar] * l_nShifter;
i_panStringBuffer += 1;
}
l_nShifter /= 64;
l_nLoop -= 1;
l_nSize -= 1;
}
}
Kochise
In Code we trust !
-- modified at 9:06 Friday 28th October, 2005
|
|
|
|
|
Can the internet explore be called from a command line and be passed a xml file to display?
Example:
C:\Program Files\Internet Explorer\IEXPLORE.EXE /C:\temp\test.xml
thanks
|
|
|
|
|
C:\Program Files\Internet Explorer\IEXPLORE.EXE C:\temp\test.xml
should work
|
|
|
|
|
Hello,
I want to draw into a DC some rotated text, drawing also the rectangle like the selection of that text. Everything works fine except...I cannot align the text vertically to the bottom of the rectangle. Function DrawText can do that but only for single line text.
I've tried also to create a bitmap with the unrotated text and rotate that bitmap but the bitmap it's not transparent and the rotation is slow...
Can anybody suggest me what to do?
Thanks in advance!
|
|
|
|
|
|
when looking up for the class members of the class CRect in the MFC documention, it seems that we can't see the following four member variables:
top,left,bottom and right. the same thing happens to many MFC classe, doesn't it?
how can I dig out these hidden members?
thank you very much!
-------------------
I am trying to love c++
|
|
|
|
|
Huh ?
which CRect are you talking about ?
you can have access to each member directly or get the TopLeft and BottomRight values as CPoint.
CRect cc;
cc.top = 1;
cc.bottom = 2;
cc.left = 3;
cc.right = 4;
CPoint topLeft = cc.TopLeft( );
CPoint bottomRight = cc.BottomRight();
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
|
what are you trying to do exactly ? i'm not sure i understand you.
you want to get these values ?
bu looking at the CRect[^] class members, you could use several operation to get what you need, such as BottomRight , CenterPoint , Height , Width , Size ...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
ewighell wrote: when looking up for the class members of the class CRect in the MFC documention, it seems that we can't see the following four member variables:
What do you mean by "see?" The CRect class is derived from the tagRECT structure, which is where those member variables come from.
ewighell wrote: how can I dig out these hidden members?
How exactly are they hidden?
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
I am sorry for not expressing myself properly.
I was just wondering why I could not see these four members in the mfc documentation.
I am new to mfc. so I want to see these members in the documentation for the CRect class before using them.
I don't konw if I have make my idea clear.
-------------------
I am trying to love c++
|
|
|
|
|
I got the answer, thank you all especially DavidCrow very much.
-------------------
I am trying to love c++
|
|
|
|
|
==========================
typedef struct
{
int a;
HWND hWnd;
HDC hDC;
}thread;
thread obj_opendevice;
void OpenDevice::Draw_PMRconnecting()
{
CWinThread *pThread = AfxBeginThread(draw_line,&obj_opendevice);
}
UINT draw_line(LPVOID param)
{
}
I have created a thread using this above code how do kill the thread
by using the handle in the structure .
HWND hWnd can i use this handle to close the thread .
I want to close the thread from anyexternal function so i cannot
use the AfxEndThread(0);
thank you
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
See here.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
vikas amin wrote: do kill the thread
by using the handle in the structure
TerminateThread(...), but you must read remark section of this api in the MSDN
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Hii everyone;
I want to print a text output from a USB port attached printer with in my code. I am sending u the details of my code as an attachment.Basically this is the test application and i need to print the text(say "HelloWorld") on the printer using openPrinter, writePrinter,StartDocPrinter,StartPagePrinter API's. I have checked all the returned value of the API & all are working fine.
OpenPrinter return non Zero and gives the handle
StartDocPrinter return the JobId
WritePrinter returns non Zero
WritePrinter(hPrinter,(LPBYTE)(LPCSTR)_T(cstrTest),cstrTest.GetLength(),&pcWritten)
where
hrinter = Handle to the printer
cstrTest = CString cstrTest = "HelloWorld"
pcWritten = bytes written to the printer.
But after all is working fine , i am not getting any output from the printer. When my command executes then in the printerprinting document the status is printing after sometime it become deleting it goes off.
Can anyone suggest me to comeback.Remember i don't want to use StartDoc, StartPage API's. Basically i need RAW data to send to print & i don't want to take the Device Context of the Printer.
-------------------------------------------------------------------------------------
void MyFunction()
{
HANDLE pHandle;
DOC_INFO_1 pDocInfo;
memset(&pDocInfo, 0, sizeof(pDocInfo));
pDocInfo.pDatatype = "RAW";
pDocInfo.pDocName = "MyPrintControl";
pDocInfo.pOutputFile = NULL;
PRINTER_DEFAULTS lpdef ; // this is for the parameter in the OpenPrinter API.
ZeroMemory(&lpdef, sizeof(lpdef));
lpdef.DesiredAccess = PRINTER_ACCESS_USE;
lpdef.pDatatype = "RAW";
DWORD pcWritten = 0;
char cBuffer[30] = "My Testing\f"; // \f is for form feed
char cBuffer[10] = "ToPrint";
int x = -1;
if(x=OpenPrinter( "Lexmark 2200 Series" ,&pHandle ,NULL /* &lpdef*/))
MessageBox("OpenPrinter Successful","OK") ;
else
ShowError();
int JobID = 0;
if(JobID = StartDocPrinter( pHandle , 1 , (LPBYTE) &pDocInfo) )
MessageBox( "StartDocPrinter Successful" , "OK" ) ;
else
ShowError();
if( x = StartPagePrinter(pHandle))
MessageBox("StartPagePrinter Successful","OK");
else
ShowError();
if(x=WritePrinter( pHandle, cBuffer, sizeof(cBuffer), &pcWritten ))
MessageBox("WritePrinter Successful","OK");
else
ShowError();
EndPagePrinter(pHandle);
EndDocPrinter(pHandle);
ClosePrinter(pHandle);
}
|
|
|
|
|
Have you considered the following:
StartDoc();
StartPage();
TextOut();
EndPage();
EndDoc(); This is how I've always printed. I'm not sure what those other functions you are using do.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
Hii ;
Thanx For ur reply . can u plz paste the below code. & Tell me whether it is working or not .I mean to say that whether "TestPage_Please check it" is printing on 10,10 point on paper.
Plz check it.
void ForPrint()
{
HDC hdcPrinter;
static DOCINFO DocInfoStruct;
DocInfoStruct.lpszDatatype = "RAW";
DocInfoStruct.lpszDocName = "TestDocumentthrough DC";
DocInfoStruct.lpszOutput = NULL;
hdcPrinter = CreateDC("winspool","Lexmark 2200 Series",NULL,NULL);
//"winspool" is the name of the Driver
//","Lexmark 2200 Series" is the Printer name u can rename it wioth ur printer
StartDoc(hdcPrinter,&DocInfoStruct);
StartPage(hdcPrinter);
SetTextAlign (hdcPrinter,TA_CENTER) ;
BOOL bRet = TextOut(hdcPrinter,10,10,"TestPage_Please check it",20);
//It should print the Output on the point(10,10) & 20 letters
//should be printed
EndPage(hdcPrinter);
EndDoc(hdcPrinter);
}
|
|
|
|