|
What are you trying to do ? VerifyKeyA is a function, not a variable.
Ah, I think I know. You know some VB, but you don't know C++ ? You need to create a new variable to return. Also, you should use bool, not BOOL, which is just a macro for people using C ( which did not have bool ). BOOL is an int.
boolCACR120RWBLOCK1Dlg::VerifyKeyA(int SectorNo)
{
bool result = false;
// insert code here to set result to true if appropriate.
return result;
}
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Lets see if I can explain this.
I have an app.exe (basically a test app) which loads, via LoadLibrary, mainDLL (which exports c-style functions as an api) that uses libraryDLL which contains class definitions which are exported.
app.exe passes hInstance to mainDLL via DllMain. mainDLL uses classes defined in LibraryDLL. It appears that libraryDLL is loaded everytime an exported class is used by mainDLL (as expected I guess, but this isnt my confused point)
The problem is when libraryDLL gets hInstance, its always the handle of app.exe and not mainDLL. I need libraryDLL to use retrieve mainDLL handle and name because other files are used based on the mainDLL name.
Questions:
- How do I get libraryDLL to get the handle of mainDLL?
- libraryDLL is always loaded first. Can I control this? I'm guessing I cant since its not an api dll but exported classes
- Why does mainDLL return the handle of app.exe when I call GetModuleHandle(NULL) instead of the handle for mainDLL?
- Do I need a DLLMain in both mainDLL and libraryDLL?
If so, should I use hInstance? If so, hInstance is always of the wrong module so why use it?
Is it apparent I"m confused? ANy help or articles to read would be appreciated.
TIA
-C
|
|
|
|
|
Wheatbread wrote: Why does mainDLL return the handle of app.exe when I call GetModuleHandle(NULL) instead of the handle for mainDLL?
First read the MSDN well. it says
"If this parameter is NULL, GetModuleHandle returns a handle to the file used to create the calling process (.exe file)."
The module handle of the mainDLL will be passed to the DllMain of the mainDLL ( HINSTANCE ). Save that HINSTANCE so that you can pass that value to the libraryDLL when need.
Another option is to use the below code to get the module handle
MEMORY_BASIC_INFORMATION stMemoryInfo; <br />
static int nAddress; <br />
if( !VirtualQuery( &nAddress, &stMemoryInfo, sizeof( stMemoryInfo ))<br />
!= 0 )<br />
{ <br />
return false; <br />
}<br />
HMODULE hModule = (HMODULE)stMemoryInfo.AllocationBase;
|
|
|
|
|
hi all,
in vb the function declaration is like this
Hex_Dec(val$, ByVal start As Byte) As Byte, how shall i declare the same fuction in VC++. please help me i am fresher.
thanku,
savitri
|
|
|
|
|
savitri wrote: Hex_Dec(val$, ByVal start As Byte) As Byte
What does this function do?
Maxwell Chen
|
|
|
|
|
hi maxwell Chen,
we use this to convert hex number but i am not getting how to declare that function why that $ is used..
Hex_Dec(Mid("FFFFFFFFFFFF", 1, 2), 1)
thanku
savitri
|
|
|
|
|
savitri wrote: we use this to convert hex number but i am not getting how to declare that function why that $ is used..
I don't quite get what you meant, and I do not read VB code / syntax.
I guess you are going to format a byte value in hexadecimal display. There are some existing functions for this job. You don't have to write your own.
Take a look at itoa function.
Or you can use the below:
char sTmp[10] = {0};
char val = 0xAB;
sprintf(sTmp, "%X", val);
Maxwell Chen
|
|
|
|
|
savitri wrote: but i am not getting how to declare that function why that $ is used..
Appending the identifier type character $ to any identifier forces it to the String data type.
So you neither know VB.
|
|
|
|
|
savitri wrote: Hex_Dec(val$, ByVal start As Byte) As Byte, how shall i declare the same fuction in VC++.
May be the following useful,
BYTE Hex_Dec(TCHAR *val, BYTE start);
But function and variable declaration are basics you need to learn these language constructs. Refer book, online tutorial, and compare with VB.
|
|
|
|
|
dear all
i would like to convert RGB image to grayscale, however i couldn't, how to convert y = Rx0.3+Gx0.59+Bx0.11) below?
int iWidth=m_vicImg.endx-m_vicImg.stx+1;
int iHeight=m_vicImg.endy-m_vicImg.sty+1;
int iBuffwidth=m_vicImg.buffwidth;
unsigned char *ucImgdata=m_vicImg.ibuff;
for(int iY=0;iY<iheight;iy++)>
{
for(int iX=0;iX<iwidth*3;ix+ mode="hold"> {
ucImgdata=(0.3*ucImgdata[iX+2] + 0.59*ucImgdata[iX+1] + 0.11*ucImgdata[iX]);
}
ucImgdata+=iBuffwidth;
}
error C2440: '=' : cannot convert from 'double' to 'unsigned char *'
i know ucImgdata type is different with what we signed in left, but i can't do correctly. anyone help me, thanks
Li Zhiyuan
|
|
|
|
|
li zhiyuan wrote: ucImgdata=(0.3*ucImgdata[iX+2] + 0.59*ucImgdata[iX+1] + 0.11*ucImgdata[iX]);
error C2440: '=' : cannot convert from 'double' to 'unsigned char *'
may be the following useful,
ucImgdata[iX+2] = ucImgdata[iX+1] = ucImgdata[iX] =(0.3*ucImgdata[iX+2] + 0.59*ucImgdata[iX+1] + 0.11*ucImgdata[iX]);
but i think the current available code is not written yourself. you need to be familiar with basic array, pointer concepts.
|
|
|
|
|
Rajkumar R wrote: but i think the current available code is not written yourself. you need to be familiar with basic array, pointer concepts.
People here keep telling him this, but he just doesn't listen ...
Maxwell Chen
|
|
|
|
|
Maxwell Chen wrote: People here keep telling him this, but he just doesn't listen ...
Right you say...!but could we try to find why yuo he don't want to listen.. any language problem, since by name he seems to no english speaking country!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/codeProject$$>
|
|
|
|
|
ThatsAlok wrote: but could we try to find why yuo he don't want to listen.. any language problem, since by name he seems to no english speaking country!
If I recall correctly, "li zhiyuan" is from China and now lives in Malaysia.
Maxwell Chen
|
|
|
|
|
ohh great!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/codeProject$$>
|
|
|
|
|
You code still doesnt look correct enough. In image processing, normally we write in this way;
x_start,y_start, x_end, y_end are the coordinates for your ROI (Region of Interest)
Also note, the RGB image is 24-bit (hence the 3 = 24/8). Array indexing is used as x*depth + y *depth*image width (not region width)
Also note, on IA-x86 (Intel Arch), RGB in memory comes as BGR
for(int y = y_start; y < y_end; y++)<br />
for(int x = x_start; x < x_end; x++)<br />
{<br />
pImageGray[x+y*width] = pImageRGB[x*3 + y*width*3 + 0]*0.112 + pImageRGB[x*3 + y*width*3 + 1]*0.59 + pImageRGB[x*3 + y*width*3 + 2]*0.33;<br />
<br />
}
|
|
|
|
|
li zhiyuan wrote: error C2440: '=' : cannot convert from 'double' to 'unsigned char *'
See here.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi,
some website ask you to input some identify code
But I don't know how to identify the code,
could you help me ?
Could you give me some code?
Thank you
|
|
|
|
|
What on earth are you talking about ? Do you mean CAPTCHA ? The reason they do that, is to stop people from being able to 'identify' them with code.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I am trying to use POST url to the server using CInternetSession ,CHttpConnection,CHttpFile
But I am getting exception when excuting EndRequest
The format i have to post is:
POST /axis-cgi/audio/transmit.cgi HTTP/1.0\r\n
Content-Type: audio/basic\r\n
Content-Length: 9999999\r\n
Connection: Keep-Alive\r\n
Cache-Control: no-cache\r\n
\r\n
<Audio data>
<Audio data>
<Audio data>
My Code is :
CInternetSession session;
CHttpConnection *m_pConnection;
CHttpFile* pHTTP;
CString strPreFileData;
strPreFileData = "Content-Type: audio/basic\r\n";
strPreFileData += "Content-Length: 9999999\r\n";
strPreFileData += "Connection: Keep-Alive\r\n";
strPreFileData += "Cache-Control: no-cache\r\n";
strPreFileData += "\r\n";
CFile fTrack;
if (FALSE == fTrack.Open(strFullPath, CFile::modeRead ))
{
AfxMessageBox(_T("Unable to open the file."));
return FALSE;
}
dwReadLength = fTrack.Read(pBuffer, 200);
m_pConnection=session.GetHttpConnection("10.200.11.63", (INTERNET_PORT)80, "root", "root");
pHTTP = m_pConnection->OpenRequest(CHttpConnection::HTTP_VERB_POST, "axis-cgi/audio/transmit.cgi");
pHTTP->AddRequestHeaders(strPreFileData);
pHTTP->SendRequestEx(240,HSR_INITIATE,0);
pHTTP->Write(pBuffer, 240);
pHTTP->EndRequest();
Please Help me regarding this
S.Yamini
|
|
|
|
|
Hello everyone,
We alway meet with the term reallocation, but after some deep thinking, I am confused what exact definition of what means reallocation. Here is some statements from the book The C++ Standard Library as quoted below.
My two questions,
1. How do you understand the term reallocation in the book quoted section?
2. Are there any standard definition for reallocation?
My understanding, reallocation means making storage larger or smaller (or making the same size, but different address? not sure?), whether or not it involves free existing memory (e.g. vector) or not (e.g. deque) depends on internal implementation. It is hard to find a suitable definition for reallocation, if you have, please share with me.
section 6.3.1 Abilities of deques
--------------------
Deques provide no support to control the capacity and the moment of reallocation. In particular, any insertion or deletion of elements other than at the beginning or end invalidates all pointers, references, and iterators that refer to elements of the deque. However, reallocation may perform better than for vectors, because according to their typical internal structure, deques don't have to copy all elements on reallocation.
--------------------
thanks in advance,
George
|
|
|
|
|
Hi George,
reallocation to me means:
1. performing a new allocation (at a new address)
2. copying the existing data to it
3. returning the new address
It is used to change the size of some data structure (e.g. an array) without loosing its
content, typically when you want to add data but can't without all the steps involved,
since the existing allocation isn't large enough. Occasionally it is also used to reduce
size (when the original allocation was way too large, typically because requirements
initially unknown).
You could have a look at the realloc() function in C.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Thanks Luc,
Cool! Question answered.
regards,
George
|
|
|
|
|
I used
Font *pFont=::new Font(L"Tahoma",12,FontStyleRegular,UnitPixel);
to create a Font object, when I do Graphics::DrawString using this font, the font is in bold style.
PS: I've Tahoma.ttf in the font directory.
|
|
|
|
|
You shouldn't necessarily be using the global namespace new operator for GDI+ objects.
If you use DEBUG_NEW and that's causing ambiguity with Gdiplus::new, you can get around it as shown below.
I tried this and it wasn't bold
#pragma push_macro("new")
#undef new
CClientDC clidc(this); <font color="Green">
Gdiplus::Font *pFont=new Gdiplus::Font(L"Tahoma", 12, FontStyleRegular, UnitPixel);
Graphics gr(clidc);
PointF origin(0.0f, 0.0f);
SolidBrush blackBrush(Color(255, 0, 0, 0));
gr.DrawString(L"abcdefghijklmnop", 16, pFont, origin, &blackBrush);
delete pFont;
#pragma pop_macro("new")
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|