|
|
Arman Z. Sahakyan wrote: // l->pszInFile = bufferwithpath;
// l->pszOutFil = w_Output;
l->pszInFile = (LPWSTR) malloc( 2 * wcslen(bufferwithpath) );wcscpy(l->pszInFile, bufferwithpath);l->pszOutFile = (LPWSTR) malloc( 2 * wcslen(w_Output) );wcscpy(l->pszInFile, bufferwithpath);
HI !
arman when can we need to allocate the memory to the variable? In the above case
I have just try to assign that i know its wrong but , the basic question is when
can we should allocate memory?
I know that array already occupay memory at compile time , and I also konw that
we can allocate memory runtime by malloc/calloc or new in c++, but where and in which condition we have to use it.
please regret me about my spells and english.
can you kindly explain me?
"Success lies not in the result , But in the efforts !!!!!"
Amit Mistry - petlad -Gujarat-India
|
|
|
|
|
amitmistry_petlad wrote: well now all threads are working and running but then it use the same paramters for all the thread. I confuse here why ???
thats just LPVOID.. you can typecast anything into it!
"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
Support CRY- Child Relief and You
|
|
|
|
|
Given a MFC process and a .NET service, how does the MFC process communicate with the .NET service?
Which IPC should I use?
Thanks.
|
|
|
|
|
|
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
talihsu wrote: how does the MFC process communicate with the .NET service?
Is it your service or a 3rd party service?
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
It's my service. So the MFC process does.
|
|
|
|
|
Here's a few options...
You should be able to use any of the regular methods listed here: Interprocess Communications[^]
You can also use .NET Remoting[^] but that'll require managed code on the MFC side.
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
talihsu wrote:
It's my service. So the MFC process does.
com will help in this case!
"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
Support CRY- Child Relief and You
|
|
|
|
|
I have a dropdown combo that I am populating dynamically based each character (I trap CBN_EDITCHANGE) that the user types in the edit box portion. I'd like to be able to highlight the first entry in the dropdown (so the user could arrow down if they want) WITHOUT losing the data in my editbox. (I've already subclassed the listbox so I can get rid of the "hover cursor selection") Any thoughts on how to do this? Any help would be appreciated.
|
|
|
|
|
Hi All,
In an effort to keep my mind active, I've decided to attempt to learn Unmanaged C/C++ - ideally C first and ++ later - however given the range of books and tools available, I wondered if anyone had any recommendations they could share?
In terms of tools, I have VS2005 Pro but every time I fire it up and open a MFC project i quickly get lost (and I think I'm right in thinking that a lot of what you can do in VS2005 is tied to MS platforms?), so if anyone can recommend a equally good (but hopefully more streamlined!) IDE for C, I'd be glad to hear it!
TVM,
Martin.
|
|
|
|
|
There is a free IDE called 'Dev C++' (Google for it's URL). You can do both C and C++. For a free IDE, it's pretty good. If you want to use VC++ as your IDE, try creating your applications as: Win32 Console Application or Win32 Application.
Learn C first before jumping stright into C++. Read about object-oriented programming before tackling C++, and learn about 'event-driven' programming before you step into using MFC. One book that I used when learning MFC (and I'm by no means an expert) was 'MFC Programming' by Ivor Horton. Hopefully, there is an updated version which covers the latest MFC IDEs.
Good luck, and don't get frustrated. It will take you probably 6 months after starting to use C++ before you feel comfortable with it.
John P.
|
|
|
|
|
jparken wrote: Learn C first before jumping stright into C++.
My advice would be the opposite.
Steve
|
|
|
|
|
Stephen Hewitt wrote: My advice would be the opposite.
So is this how you would say it in an opposite way?...
Learn C++ first before jumping straight into C. Read about C++ before tackling object-oriented programming, and learn about MFC before you step into using 'event-driven' programming . One book that I would never recommend when learning MFC (and I'm an expert) is 'MFC Programming' by Ivor Horton. Hopefully, there is not an updated version which covers the latest MFC IDEs.
|
|
|
|
|
Once you know C++, learning C is simply a matter of learning what's missing (for the most part). Learning C++ teaches you better coding habits however. That's how I was taught it at uni. The lecturers tried it both ways and found this way the best (or so I was told).
Steve
|
|
|
|
|
Structured programming is much easier for a first semester in programming.
We actually started with Pascal in High school and college and C was offered next in the progression with Pascal as a prerequisite.
|
|
|
|
|
I disagree. Object oriented programming is very intuitive because it lines up with the way people naturally think. That's why it was invented: to help manage the ever increasing complexity of software development by making it easier to understand. I don’t think of a door as a set of states and disconnected functions for manipulating and interrogating the state but rather as a single object. It’s often harder for people who have learnt structured programming first because they have to change their mind set, but that’s not the point under discussion.
Steve
|
|
|
|
|
bob16972 wrote: Learn C++ first before jumping straight into C.
Yep.
Learn proper object-oriented design and architecture, before stepping into the world of wonders of C.
Too many people try to write C++ as if it were a C with classes.
C is a sophisticated macro-assembler. C++ is an object-oriented language with the possibility to fall back to C.
Failure is not an option - it's built right in.
|
|
|
|
|
jhwurmbach wrote: C is a sophisticated macro-assembler.
I think this is the bit I'm most interested in... not least, because I don't even know what that means!
|
|
|
|
|
20 years or so ago, I made the change from Pascal / Basic / whatever was handy to C.
I learnt C programming, and have never made the step to C++ - it just didn't seem to have any real benefits. And yes, I have heard about code reusability, encapsulation, and all those supposed benefits of Object-Oriented Programming. They just don't seem to be enough of an advantage that it's worth changing my way of doing things.
I even bought some books - the first 20 pages of each are well-thumbed, but then the concepts (sorry, "paradigms") became so ridiculous and contrived, I gave up each time.
Unfortunately, the world has moved on. Everyone except me has moved from C to C++ to C#. Sob.
So to avoid my experience, I would advise skipping the ANSI C stage, and moving straight to C++ or C#. But since I have not done this, I can't recommend any books.
|
|
|
|
|
Hello everybody
I am trying to make a proxy(/wrapper) dll for wsock32.dll.
Therefore i used the script found here: "http://www.codeproject.com/dll/CreateYourProxyDLLs.asp"
The "default" result of this script (with the asm jmp functions) works perfectly, but when i try to manipulate
the parameters passed to my proxy functio. i get an access violation error.
i am trying to "proxify" the send function
according to MSDN ( http://msdn2.microsoft.com/en-us/library/ms740149.aspx) :
int send(
SOCKET s,
const char* buf,
int len,
int flags
);
Therefore i replaced script generated functions:
-------------Code--------------
// send
extern "C" __declspec(naked) void __stdcall __E__69__()
{
__asm
{
jmp p[69*4];
}
}
-------------Code--------------
With my own ( for handeling the parameters )
-------------Code--------------
// customizable send
extern "C" int __stdcall __E__69__( SOCKET s, const char* buf, int len, int flags )
{
//we must type cast the "remote" function
typedef int (*__stdcall ps)( SOCKET, const char* , int , int);
ps PX;
PX = (ps)p[69*4];
//Returning response from real dll
return (*PX)( s, buf, len, flags );
}
-------------Code--------------
and compile the above.
Compiling goes without warning or erors.
If i then place the proxy dll along side the original dll (properly named)
and lauch the application (which uses my proxy dll ) i get an acces violation like the following:
------------------------Error-----------------------------------
This application has encountered a critical error:
Error #132 (0x85100084) Fatal Exception
Exception: 0xC0000005 (ACCESS_VIOLATION) at 001B:00000000
The instruction at "0x00000000 referenced memory at "0x00000000".
The memory could not be "read"
Press OK to terminate the application
------------------------Error-------------------------------------
With the following stack trace:
------------------------Stack Trace-----------------------------------
10001A3B WSOCK32.dll __E__69__+27 (0x00002454,0x0012FDF7,0x00000001,0x00000000) (wsock32.cpp,756)
00603AAD WoW.exe <unknown symbol="">+0 (0x00000000,0x00000000,0x00000000,0x00000000)
------------------------Stack Trace-----------------------------------
I would be very gratefull if someone could help me solve this problem.
Thanks in advance
|
|
|
|
|
Cloather2 wrote: 10001A3B WSOCK32.dll __E__69__+27 (0x00002454,0x0012FDF7,0x00000001,0x00000000) (wsock32.cpp,756)
00603AAD WoW.exe +0 (0x00000000,0x00000000,0x00000000,0x00000000)
If that WoW.exe is World Of Warcraft, and you are trying to crack the C/S protocol or create some kind of cheating (aiming/environmental) proxy, you are far out of your league if you are getting problems like this...!
Peace!
-=- James Please rate this message - let me know if I helped or not!<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! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Ye i get it, ill go somewhere else
-- modified at 2:24 Friday 11th May, 2007
Solved it myself by:
putting following type def at top of file:
------------Code-------------------
typedef void (CALLBACK *PTTOSEND)(SOCKET, const char*, int, int);
Instead of the default array var to hold the func pointer i created my own var like this:
------------Code-------------------
ptToSend = (PTTOSEND) GetProcAddress(hL,"send"); //type cast
The function call then looks like this
------------Code-------------------
// customizable send
extern "C" void __stdcall __E__69__( SOCKET s, const char* buf, int len, int flags )
{
//Returning response from real dll
return (*ptToSend)( s, buf, len, flags );
}
|
|
|
|
|
Good luck with that...!
Peace!
-=- James Please rate this message - let me know if I helped or not!<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! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|