|
I just recently learnt how to program in C/C++ and hense I have never done any coding in C# or ASP.NET... I have heard that there is a way to do this so I wanted to give it a try. I just need a head start as all.
|
|
|
|
|
S0uthy wrote: I have heard that there is a way to do this so I wanted to give it a try
Well, if the site doesn't exist yet, my strong advice is not to bother with a method that, frankly, has been out of date for at least 8 years now. You're looking to do things in a way that is
a - hard
b - not well supported
c - has no real frameworks to support it
If you know C++ syntax, C# won't be a big ask for you, and the .NET framework will do all sorts of cool stuff for you that you're never going to be able to do in c++
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi,all.
Here I have a project which needs the client transmit 4MB per second to server.I use CSocket and CArchive model in MFC with stream type socket.After it works for a while, the client can not send data any more, it seems that it has been blocked by the server's reading because the socket is set to work synchronously. Meanwhile the server is waiting for client's data, which leads to a deadlock in communication.However, no CMemoryException, CArchiveException or CFileException has been thrown out, but the client can not response any message any more (but the server remains OK).So is there any methods to avoid this?or do you all have some suggestions to improve the transmission?
|
|
|
|
|
I have declared:
typedef void (CMyClass::*LPFN_MYMETHOD)();
elsewhere in my code I have Something like:
void Func(){
CMyClass* pMyClass=(CMyClass*)GetMyClass();
LPFN_MYMETHOD pMethod=(LPFN_MYMETHOD)GetMyMethod();
// Now I want to do: pMyClass->pMethod();
// Easy symantics for humans, but aparently NOT for a compiler
}
I tried various variants, which either yielded that pMethod is not a member of CMyClass, or, that pMethod does not evaluate to a function
Does anyone know what the correct syntax is.
LateNightsInNewry
|
|
|
|
|
Further to the above, I've gotten away sofar with writing something that works well for my compiler:-
void Func(){
DWORD pMyClass=(DWORD)GetMyClass(); //Note Declaration Changed to DWORD
DWORD pMethod=(DWORD)GetMyMethod(); //Note Declaration Changed to DWORD
__asm{
mov ecx,pMyClass;
call pMethod;
}
}
This however cuts out all the expensive type checking features, and becomes highly compiler dependent. I am looking for a Syntax to do this, which fits within the language. Somewhere, deep within MSVC, Bill Gates uses this syntax to call MessageMap functions.
LateNightsInNewry
|
|
|
|
|
Try this:
(pMyClass->*pMethod)()
This is logical as pointers should be dereferenced to yield the pointee: in this case a pointer to a function should be dereferenced to yield a function.
Another comment; lose the LPFN_MYMETHOD cast: it's destructive and not needed. With this cast you disable the compiler's type checking.
Steve
|
|
|
|
|
Thanks Steve, Works as Advertised. As for the cast,I agree in the example given. Won't work in my current project, as the type to cast to is determined elsewhere in the process.
LateNightsInNewry
|
|
|
|
|
Dear Steve,
Your Answer Works,and I am gratefull for the help you gave . No Doubts or Complaints in the Making it Work Department,BUT I totally fail to see how it's logical. In Simple Language, and avoiding language used by CompilerCompiler Authors, could you explain 'how' this syntax should immediately spring to mind when face with the problem as stated.
Much Appreciated
LateNightsInNewry
|
|
|
|
|
A pointer to an integer:
int *pInt;
To refer to the integer pointed to (the "pointee") in previous example:
*pInt
A pointer to a function which returns nothing and has no parameters:
void (*pFunc)();
To call through the pointer in previous example:
(*pFunc)();
Note that in this case the star is optional but leaving it out is not consistent with the use of pointers in all other contexts.
A pointer to a class of type CFoo :
CFoo *pFoo;
To call a member function through the pointer in the previous example:
pFoo->AFunctionInCFoo();
A pointer a member function of class CFoo that returns nothing and has no parameters:
void (CFoo::*pFunc)();
To call through the pointer in the previous example:
pFoo->*pFunc();
In all cases you use the * operator to turn a pointer into a pointee (the object it points to). Just like it makes no sense to multiply a pointer to an int by 2 but it makes perfect sense to multiply the integer pointed to by 2 so it is with the pointer to a member function: you don’t call the pointer you call what it points to (a function) and the * operator is how you move from a pointer to its pointee.
Steve
|
|
|
|
|
Steve,
Never looked at this pointer resolution and declaration syntax issue from the point of view you just showed. The Logical step I Missed was the Optional Star, which I understand now, becomes a syntactical requirement where the compiler would not otherwise be able to determine the level of indirection of the Memberfunction.
thanks;P
LateNightsInNewry
|
|
|
|
|
anyone have a clue, how to perform a simple search through a ms access db in a VC++
|
|
|
|
|
You've asked this question several times now. The answer is to use ADO or DAO to connect to the database and perform SQL on it. Realistically, if you have a project that requires you to do this, you'd do better to buy a book if you have no idea how to do it from start to finish. Are you already connected to the DB ? Then you should read the MSDN reference on the classes you're using.
What version of VC++ are you using ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi,
I am trying to create and then use a VC++ DLL in C#. I created the DLL in Visual Studio 2005. I just built the dll without adding any function of mine to it. That is, it is a dll that exports symbols and has the following pre-defined export symbols/functions.
// This is an example of an exported variable
TEST_API int ntest=0;
// This is an example of an exported function.
TEST_API int fntest(void)
{
return 42;
}
where,
#define TEST_API __declspec(dllexport)
Then I created a simple VC# empty project ( in Visual Studio 2005) and added the class "test" to it. When I add the VC++ dll as a reference I get this error .... "A reference to "../test.dll" could not be added. Please make sure that the file is accessible, that it is a valid assembly or COM component".
Even though I dont think it needs a conversion from COM to COM+, I even tried doing "tlbimp". I went to the command prompt for Visual Studio 2005, followed the path to where my dll resides and used the tlbimp command. But I got the error that test.dll is not a valid type library.
Someone told me that I need to register the dll using regsrv32 and it would show in my COM list when I am adding it as a reference. But that didnt work either. When I run the regsrv32, I get the error message as "..\test.dll was loaded, but the DLLRegisterServer entry point was not found" ...
I just want to know that what is it that I am doing wrong? Is there something else that I should be doing ?
All I did for creating the test.dll was ...... I went to File->New->Project. Under Visual C++ I selected Win32 and then Win32 Project. In the Application settings I selected the DLL and then checked the export symbol box. I simply built the project and was trying to use it.
Thanks for your time.
Saania
|
|
|
|
|
OK, you're a bit lost here.
You are not creating a COM dll, let alone COM+. You're writing a plain, vanilla, dll. You need to use p/invoke to call methods on this dll. If you're writing it from scratch, I'd be more inclined to use C++/CLI to write a DLL that IS an assembly and which can be imported.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Thanks for the reply, but there is one problem still .... I am not creating a DLL from scratch. I have a project in VC++ (written by someone else) and I want to use it from my VC# code, so for that I first have to convert the VC++ project to a dll ~ right !! Or is there some other way I can use the project in my VC# code.
Thanks once again.
|
|
|
|
|
If you're converting to a dll, I assume you're hoping to access some classes in there, not execute any sort of UI ? You can compile with /clr and write a managed layer that you can import into C#. Which is easier really depends on the code you're working on.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi I have two 'LPSTR' (or char *) variables and I need some help in figuring out how to insert a number inbetween these two and join (strcat) the two LPSTR variables. I apperciate any help I can get, Thanks!
Ex:
LPSTR test1;
LPSTR test2;
test1 = "hello";
test2 = "world";
int x = 9;
char buffer[10];
itoa(x,buffer,10);
//I need to end up with 'hello 9 world'
|
|
|
|
|
You can do this:
char test1[256];
char test2[256];
sprintf(test1, "hello");
sprintf(test2, "world");
int x = 9;
char buffer[256];
sprintf(buffer, "%s %d %s", test1, x, test2);
the buffer will contain 'hello 9 world'
Chipper Martin
|
|
|
|
|
|
I have a network device app that resides in the system tray. I added a context menu to this app to enable and disable the device. Right now I'd like to add an additional context menu item to display the Windows "Network Connections' dialog box. This is the same dialog that one sees on clicking "Network Connections" in the Control Panel.
Has anyone tried this before? Would appreciate any help in this regard.
Thanks.
|
|
|
|
|
I would like to help but i am not sure about what i write below, just try it.
since it is a control panel application, you might use WinExec or Shell execution functions to execute the .cpl file...
hope this helps
And ever has it been that love knows not its own depth until the hour of separation
|
|
|
|
|
Hello all, I'm trying to restrict the left pane of a split window to a certain size. For instance, the left pane should not be allowed to get smaller than 100 pixels, but it can get wider; same for the right pane. There is a minimum arg when creating pane, but that just means if it gets under 100 pixels, it closes all the way up. I would like for it to not get any smaller than 100 pixels. I've seen articles that tell you how to lock the bar, but this is not what I want.
Thanks in advance.
|
|
|
|
|
BD,
I worked with some splitter stuff like this in ancient memory. Right off the top of my head, I'd suggest you take a look at handling the resizing messages as I recall that's how I did it. I don't remember if it was as simple as WM_SIZE, but look at the splitter wnd documentation & see what size oriented messages they respond to.
I do realize this is a bit vague, but it might point you down a productive path. Hope it helps.
|
|
|
|
|
Hi all,
I want to include a zip utility in my Windows Mobile application, so is there a free open source zip compression library? and if there are many, what is the best one???
Mohammad
And ever has it been that love knows not its own depth until the hour of separation
|
|
|
|
|