|
Hi all,
First method given by Naveen.R with char only is perfect for me.
Thank you all for time.
Regards.
L.
|
|
|
|
|
You are joking right! No!
Well if you know the size of the array as shown then:
CString message;
message.Format("%s%x%x%x%x","Hello", HexPrepend[0], HexPrepend[1], HexPrepend[2], HexPrepend[3]);
That’s bad C++ (MS thing), but good C.
I could give u a dozen other examples, but I am not in the mood and a little research (very little) will answer your question.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
Whenever I come here to post a question or see your discussion, I click the homepage POST A QUESTION to come here, Is there any more easy way to come to the question board?
BELOW is my question too.
what does this mean?
<br />
if (GetKeyState(VK_SHIFT) & 0x8000)<br />
{<br />
}<br />
ACTUALLY 2 questions.
-- modified at 0:35 Thursday 1st November, 2007
|
|
|
|
|
Well personally I have this shortcut[^] on my local homepage.
GetKeyState(...) returns a short, if the requested key is down then the high order bit is 1, so by masking the returned short with 0x8000 the result tested by if will be zero if the key is up and non-zero if the key is down ignoring all the bits which you dont care about because you only want to know if the shift key is down.
|
|
|
|
|
fantasy1215 wrote: if (GetKeyState(VK_SHIFT) & 0x8000)
Means the key should be kept pressed.
- NS -
|
|
|
|
|
Then does this code means clearly?
<br />
BOOL bShiftKeyDown = GetKeyState(VK_SHIFT) < 0;<br />
if (bShiftKeyDown)<br />
{<br />
}<br />
thx you all, I understand GetKeyState more clearly.
|
|
|
|
|
May be...
But actually the bit is checked there. Not simply its value. You will understand it clear from MSDN documentation regarding this. See this...
Return Value
The return value specifies the status of the specified virtual key, as follows:
. If the high-order bit is 1, the key is down; otherwise, it is up.
. If the low-order bit is 1, the key is toggled. A key, such as the CAPS LOCK key, is toggled if it is turned on. The key is off and untoggled if the low-order bit is 0. A toggle key's indicator light (if any) on the keyboard will be on when the key is toggled, and off when the key is untoggled.
- NS -
|
|
|
|
|
The high-order bit (0x8000) is the sign bit in a short variable. If it is on, then the value is < 0. This does the same thing as the code you posted earlier - it's just not as clear in this case. The earlier one would be preferable, IMHO, since it is obvious that you are testing for the state of the high-order bit.
Judy
|
|
|
|
|
I have been given a .NET Dll which I have to intergrate into and MFC solution. It sort of worked when I added it to Microsoft sample MFC04.exe sample, and imported it into one of it's Dlls. It gave a problem with passing strings to the MFC code but that should be easy to overcome.
Creating a new project in the existing solution with the same settings first gave build error with unresolved external (the lib file never was built).
Finally it builds but at runtime I get this:
Debugger:: An unhandled non-continuable exception was thrown during process load
The program '[2436] AppMgr.exe: Native' has exited with code -1073741511 (0xc0000139).
Any assistance, suggestions to get round this would be most welcome.
Happy programming!!
|
|
|
|
|
do u use
#using <dllname>
using namespace <dllname>
and then compiling with clr option?
calling .net dll from mfc dll has a mixed dll loading problem. but works if u use in a mfc app.
Prasann
|
|
|
|
|
i mean
#using dllname
using namespace dllname
|
|
|
|
|
What is the lib file you refer to?
Dynamically linking a .NET assembly has nothing to do
with a lib file.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
That's interesting, cause the Microsoft example generates a lib for ".NET/MFC interface" Dll and links with it. The interface Dll uses the namespace for the .NET, yes, and that part works when I add it to the Microsoft sample. That Dll (Which is an MCF extension) then exports a C/C++ function which accesses the .NET dll.
The error I'm getting now seems to be to with initialization when the dll is being loaded. It is trying to initialize both the managed and unmanaged code at the same time, and this is apparently a no-no.
How can I get around this? It's much work to work to rewrite the umpteen other files in the solution.
Happy programming!!
|
|
|
|
|
So it's a mixed-mode DLL, not a pure .NET DLL?
Or is there another DLL involved between a .NET assembly and the MFC app?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Yes it's the mixed mode dll I'm getting something wrong in.
No there is an MFC dll accesing the Mixed mode dll which in turn accesses the .NET assembly.
Happy programming!!
|
|
|
|
|
Ok, I think I'm following now
I would first make sure that you're following all the rules
for an MFC extension DLL, as explained here:
Extension DLLs[^]
Initializing Extension DLLs[^]
You should be able to link the app to the extension DLL (both the static link to the lib
file at build time and the dynamic link at runtime) with no errors.
Once you have that, the .NET DLL should be much simpler, since that linking
is done by the assembly loader.
If you still have the problem, it could be a loader-lock issue.
Are you making any calls besides the required MFC initialization (as described in the
links above) in your extension DLLs DllMain()? If so, I would comment those out and
test - that's where most DLL load problems occur.
Global/static variables can be a problem as well.
That's all I can think of off hand. If you still get the error, can you post
the contents of your debugger output window?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Something else I have observed that confuses me is when I select the mixed mode dll as a dependency in the MFC dll it's lib is automatically added to the linker command line. However once I selected /clr on the mixed mode dll that command line entry is automatically removed and causes unresolved externals. In the MS sample this does not seem to be case.
I'm therefore thinking that my problems are to do with compiler/linker settings.
If I start with the mixed mode dll as a pure MFC extension it works fine both implicit and explicitly linked at runtime.
as soon as I add the /clr flag the problems start, before I even add the .NET dll to the references.
Happy programming!!
|
|
|
|
|
Now that I have much finally building and running correctly, can you point me to an article or make a suggestion on how I can get error information when the .NET code throws an exception.
try<br />
{<br />
CallToDotNetCode();<br />
}<br />
catch(...)<br />
{<br />
}
This works fine in as much as catching the exception and I can return a value to indicate something has gone wrong. However I would like to extract the reason for the exception. If I put any sort of parameter into catch it stops working, so there must be another way of doing this which works reliably.
Happy programming!!
|
|
|
|
|
hi guys, i'm having a problem using malloc() since it only accepts a paramter of size_t which is an unsigned int ... my problem is i have this 350+ million elements for my array of structure with sizeof 16 bytes... meaning i get to have an array size of 5+ billion bytes which obviously cannot be contained on an unsigned int variable.. so my question is how do i get through this problem? is there another way of allocating memory with bigger parameters?
|
|
|
|
|
why don't you try to allocate a portion of the data first? process it then allocate and proceed to the next.
|
|
|
|
|
well, the program im using right now uses all the contents of the array to get compute certain functions... it would be cumbersome to fetch these data all the time when i them... it will take a lot of time retrieving it since the data is found on a very large file (about 10 gig)
|
|
|
|
|
you can try making a linked list structure which has the variable that you will allocate. the program can allocate the maximum that it can and when it still is not enough, create another element that your current element will point to. just repeat the process until you've allocated enough for the file.
I'd still recommend to allocate a certain size and get it from the file then process.. since ReadFile moves the file header to the next character of the last one it has read, so it won't be that much time consuming to allocate and read what you can process.
decision is up to you though.
|
|
|
|
|
still, using linked list structure, retrieving values wont be as fast as in an array though... but its a good point.. im up to speed right now, nevermind of the resources... anyways thanks for the help... it'll be a resort i'm going if i can't find another way...
anyways, i've read that malloc() can allocate 64-bit memory in 64-bit platforms... i guess i'll have to change OS then and give it a try... time to reformat my pc..
|
|
|
|
|
In this case I would give serious consideration to the function MapViewOfFile() granted it still only allows you to view SIZE_T at a time, but if you arent jumping back and forth in the array but progressing in a somewhat linear fashion I think the performance benefits would be substantial as there is no multiple buffering or copying of the huge amounts of data you have to process.
|
|
|
|
|
Entertainment tonight!
You have to deal with the pieces on a smaller scale, which is not hard to do, just slower because you have to read them from disk. Now if you do a little research, you will find that the Windows OS offers other options for allocation (virtual memory) that might solve your problem. But if you are restricted to C, or non-OS specific options, then we are back to disk reading/writing.
Use your imagination, because ‘malloc’ is not the problem. It is limited, but your imagination in not.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|