|
Ok so I'll start by declaring my undying love for C# :P it's my primary language and I try to stick to the managed world where ever possible. This time though I need to use some stuff where pInvoke just wont cut it so I'm using my lacking and very dodgy C++/Cli skills :P so please forgive me if I say anything stupid
I'm currently working with this MAPI function:
OpenIMsgOnIStg[^]
Due to the wonderful fact that it requires Memory Management Functions to be passed to it:
lpAllocateBuffer
[in] Pointer to the MAPIAllocateBuffer function, to be used where required by MAPI to allocate memory.
lpAllocateMore
[in] Pointer to the MAPIAllocateMore function, to be used where required by MAPI to allocate additional memory.
lpFreeBuffer
[in] Pointer to the MAPIFreeBuffer function, to be used where required by MAPI to free memory.
I'm not even going to go near it with pInvoke.
I've translated this article:
INFO: Save Message to MSG Compound File[^]
into a standalone native method and I'm now trying to put together the C++/Cli code to act as the go between.
The biggest problem I'm currently facing is trying to convert a System::Object into a LPMESSAGE. None of the casts seem to want to work and I'm not sure of the next direction to try :S does anyone have any suggestions on how to cast/convert?
-- modified at 6:23 Wednesday 11th July, 2007
EDIT: Realised I hadn't acctually asked a question
|
|
|
|
|
Well I'm not sure if this is the cleanest way of doing it but it works
System::IntPtr ipMsg = System::Runtime::InteropServices::Marshal::GetIUnknownForObject(iMessage);
LPMESSAGE iMessageToSave = (LPMESSAGE)(ipMsg.ToPointer());
Obviously it was the right underlying native type otherwise the way I use it later would have bombed. I'm quite chuffed with how relativly easy and painless this was
|
|
|
|
|
if I am using getchar(), then the execution of the program will stop here if no input is given.
could someone help me figure out if there is another way? Aim: while any input is given, save it to a variable, if not, keep on executing program without stop.
I have used multithread, but it did not work well when I put it running at background.
I am using C
|
|
|
|
|
bloodwinner wrote: I am using C
Then you can't be using .NET and you're in the wrong forum. Try the visual C++ forum.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi all:
I am really confused about the meaning of ^ in VS2005. I see many programs declared as something like:
String^ xxx;
MyClass^ yyy;
Can anyone explain it to me please?
Thanks very much!!!
Asura
Asura
|
|
|
|
|
Why don't you have a look at MSDN?
|
|
|
|
|
Because I didn't find it.
Asura
|
|
|
|
|
Its called a handle. Its a form of tracking pointer. The garbage collector updates the location a handle points to if it moves the data it pointed to during compaction of the managed heap.
|
|
|
|
|
Hi,
I would declared classe and methodes using .h and .cpp , he can't introduce a variables declared in .h
please help me
the .h was
#pragma once
#include "inc.h"
class abbdCap
{public:
abbdCap(void);
~abbdCap(void);
public:
int GetDeviceList();
int OpenDevice(int index);
int CloseDevice();
int ApplyFilter(int index);
u_long netmask;
int devcount;
int res;
};
the .cpp was:
#include "StdAfx.h"
#include ".\capturingpaquet.h"
using namespace System;
abbdCap(void)
{
int i;
alldevs = new pcap_if_t;
}
~abbdCap(void)
{
pcap_freealldevs(alldevs);
}
int GetDeviceList()
{
int j;
int k;
.
.
.
.
}
thank you
|
|
|
|
|
the scenario is I am counting down 5, if no 'y' has been input during this time, then it ends at one way, else it ends at another way. Because I dont expect there must be a 'y' input, I write this as multi-thread, one for counting down, one for checking the 'y' input (could be unnecessary).
this program works fine when I put it at the foreground(using linux), but when put it at background, error happens, it will stop and wait for getchar() input, and m doesnot count down. As long as I use shell command "fg" to bring it back to foreground, the count down resumes, but that is not what I want.
what I want is just: put the program execution at background, while waiting for a 'y' input during 5 seconds count down time.
void *countdown( );<br />
void *waitinput( );<br />
static int m=5;<br />
static int k=1;<br />
<br />
int main(int argc, char **argv)<br />
{ <br />
<br />
pthread_t thread1=0, thread2=0;<br />
int iret1=0, iret2=0;<br />
<br />
<br />
<br />
iret1 = pthread_create( &thread1, NULL, countdown, NULL);<br />
iret2 = pthread_create( &thread2, NULL, waitinput, NULL);<br />
<br />
<br />
<br />
<br />
<br />
pthread_join( thread1, NULL);<br />
<br />
pthread_cancel(thread1);<br />
pthread_cancel(thread2);<br />
printf("pthread been cancelled\n\n");<br />
<br />
if(k=1){...}<br />
else {...}<br />
<br />
<br />
return 0;<br />
}<br />
<br />
void *countdown()<br />
{<br />
while(m>0)<br />
{<br />
printf("%d seconds left\n",m--);<br />
sleep(1);<br />
printf("m is %d\n",m);<br />
}<br />
<br />
}<br />
<br />
void *waitinput()<br />
{<br />
char c='n';<br />
while(m) <br />
{<br />
if((c=getchar())=='y')<br />
{<br />
printf("congratulations. you entered y\n");<br />
sleep(1);<br />
m=0;k=0;<br />
}<br />
else ;<br />
}<br />
}
|
|
|
|
|
This is the C++/CLI forum. .NET threads are much easier, if you're using C++/CLI, use those. Otherwise, try the Visual C++ forum.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hello all
I have a C program that basically functions as a control loop for a DC motor. Right now, the program is two threads, one that forms a user interface where I can change parameters, and the other runs a loop to update the command to the motor. Parameters are stored in global variables accessable to both threads.
I would like now to make MATLAB able to modify these global variables or otherwise communicate with the control loop thread. Does anyone have an idea of how to open a communication channel like this? The first thing that came to my mind was just using a simple UDP socket, but I lack the proper toolbox to implement that.
Thanks in advance,
Greg
|
|
|
|
|
Your program is in C. C is not OO. There is no such thing as C/CLI. You are in the C++/CLI forum, for MANAGED C++ questions.
Try the visual C++ forum.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
LRESULT OnTest(HWND hMetin, WPARAM wParam, LPARAM lParam)
{
hMetin = FindWindow(NULL, "metin");
Sleep(5000);
//Mouse move
SetCursorPos(100, 200);
Sleep(500);
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, GetMessageExtraInfo());
Sleep(500);
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, GetMessageExtraInfo());
Sleep(500);
//This code is Keybd source of send Message
SendMessage(hMetin, WM_CHAR, 'd', 0); Sleep(100);
SendMessage(hMetin, WM_KEYDOWN, 'd', 0); Sleep(100);
SendMessage(hMetin, WM_KEYUP, 'd', 0); Sleep(100);
SendMessage(hMetin, WM_KEYDOWN, 'd', 0); Sleep(100);
SendMessage(hMetin, WM_CHAR, 'd', 0); Sleep(100);
SendMessage(hMetin, WM_KEYUP, 'd', 0); Sleep(100);
return 0;
}
------
Hi..
I am working Macro-Program of a online game.all function is success,but keymessage can't.But Text type is possible.In the online game is impossible to send the keyboard message.It maybe different the keymessage that send a device
and C++.
Ah..and To work the Network game,It's very a difficult problem.
Thanks in advance
and Now i am living in Korea ^^
Hi..
I like a C++
|
|
|
|
|
Doesn't look like C++/CLI to me....
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
It seems that your code isnt C++/CLI maybe better you ask on the Visual C++.;)
|
|
|
|
|
Hi!
My problem is how to properly create and load a static library of CxImage.
I work with Borland C++ Builder 6.
I think I don't fully understand instruction connected with files I've downloaded from www.xdp.it .
This is the first time I'm working with DLL libraries so I'm very confused
I would be very grateful for any assistance
Bieras
|
|
|
|
|
This doesn't look like a managed C++ question so you should post it on the Visual C++/MFC board.
I took a look at the site - It appears to be a c++ library so the author probably includes
header file(s) to use in your source code and lib file(s) to link with your project.
The author also appears to be a CPian, so if you go to the article(s) that he wrote about the
library, you can leave a message for him directly. See here[^] for an example.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
This episode brought to you by the letter Z
|
|
|
|
|
Thank you for answer Mark ,
but that was not exactly what I asked about. I have already read this article, but I don't understand if I have to Built given .cpp files one by one and then add them to my project or make one library file? And one more. Should I built all the files in the library or only that which contains information of the kind of
// To add a file to the library use the Project menu 'Add to Project'
and with header
#define Library
at the end ?
Bieras
PS. Sorry for my poor English, and for my questions but I'm just the beginner in that kind of programming.
|
|
|
|
|
There's a section in the article I linked to that explains it better than I ever could (I didn't write the library ) - "Using CxImage in your projects".
It looks like you need to build the libraries (with the supplied workspace/projects) and then
link to the resulting libraries.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
This episode brought to you by the letter Z
|
|
|
|
|
Is it possible to define static classes as in C#? If not, is the following sufficient:
public ref class MyStaticClass
{
public:
private:
MyStaticClass() {};
~MyStaticClass() {};
MyStaticClass( const MyStaticClass% ) {};
}; If I enable code analysis, I get warnings on the copy constructor and the destructor:
warning: CA1811 : Microsoft.Performance : 'MyStaticClass.MyStaticClass(MyStaticClass)' appears to have no upstream public or protected callers.
warning: CA1801 : Microsoft.Usage : Parameter '' of MyStaticClass.MyStaticClass(MyStaticClass) is never used. Remove the parameter or use it in the method body.
warning: CA1822 : Microsoft.Performance : The 'this' parameter (or 'Me' in VB) of MyStaticClass.~MyStaticClass():Void is never used. Mark the member as static (or Shared in VB) or use 'this'/'Me' in the method body or at least one property accessor, if appropriate.
|
|
|
|
|
You can't declare the class static but yes, static methods and member variables will give the
same behavior.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
This episode brought to you by the letter N
|
|
|
|
|
I also want to ensure that MyStaticClass cannot be instantiated. Do you think I should make the class sealed in addition to what I've listed above? And do I need to worry about operator=() ?
|
|
|
|
|
sealed is good to ensure no derived classes.
Off the top of my head, I'd say just having a private default constructor is sufficient.
Without being able to instantiate any objects of the class, the destructor, assignment operator,
and copy constructor are irrelevant.
If, after some more caffeine, I change my mind about that, I'll let you know
Mark
This episode brought to you by the letter N
|
|
|
|
|
OK. Thanks for the input. This is what I'm going with:
public ref class MyStaticClass sealed
{
public:
private:
MyStaticClass() {};
};
|
|
|
|