|
So after much jubulation and sacrifices to the gods of managed/native code I continued on with my Outlook Addin.
The native code I have is working fine untill I introduce a thread to take the workload away from the GUI thread. Now the exact same code is throwing:
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Once I have created the thread I grab a list of the items I'm interested in from Outlook (which is the main thread). I then take each of these managed object and retrive the native object (still reprisented as a System.Object) and pass them over to my C++/Cli. In the managed C++/Cli I use System::Runtime::InteropServices::Marshal::GetIUnknownForObject(iMessage); to retrive and IntPtr and then LPMESSAGE iMessageToSave = (LPMESSAGE)(ipMsg.ToPointer()); to convert it into a native object. The native object is passed to the native C++ method which dies as soon as I try to pIMessageToSave->CopyTo(), where pIMessageToSave is the same native object.
As I said ... it works fine without threading but dies with it :S
Any suggestions?
|
|
|
|
|
Hi
Can someone help me reading the .config file through vc++. Please remember that i don't want to use the Dot Net way of reading config files.
Regards
Saqib
sAqIb
"Our scientific power has outrun our spiritual power. We have guided missiles and misguided men."
Dr. Martin Luther King Jr.
|
|
|
|
|
saqib82 wrote: Please remember that i don't want to use the Dot Net way of reading config files.
In that case you have posted in incorrect forum
|
|
|
|
|
I gots some maps im trying to load for a game i'm trying to make.
these maps are in a folder called Data
I have a message box that comes up asking which of the two maps i have made i want to load.
I have made done char mapToLoad[200]; at the top.
<br />
if (MessageBox(NULL,"Load world 1?","Load World",MB_YESNO|MB_ICONQUESTION)==IDYES)<br />
{<br />
mapToLoad = "Data/World1.txt"; <br />
}<br />
else <br />
{ <br />
mapToLoad = "Data/World.txt";<br />
}<br />
Do i have to do mapToLoad[1] = D
mapToLoad[2] = A and so on? i was hoping there was an easier way thats why i tried this.
After that i have
filein = fopen(mapToLoad, "rt");
This should work right?
The majority of code i have in the project is from the NeHe opengl tutorial here http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=10[^]
thx
|
|
|
|
|
Use a list view or a combo box to allow the user to choose the map he wants
|
|
|
|
|
I probly should have said this earlier. I am using bloodshed dev-cpp not microsoft visual studio. So i
don't have access to those sorts of things. And i think i mentioned before i'm using opengl. I dont
think a windows combo box will work with an opengl program?
The only other way i can think of doing it is to have a seperate loading thing for each map and go if
<br />
messagebox == true <br />
{<br />
whole loading procedure for world.txt<br />
}<br />
else<br />
{<br />
whole loading procedure for world1.txt<br />
}<br />
this seems like alot of extra code to be compiling to me.
So i don't think this is a viable option either.
I really just need to know how to stick the location of the file into a char and then use that char in
place of the first char argument of fopen(const char*, const char*)
thx
|
|
|
|
|
nzadLithium wrote: I am using bloodshed dev-cpp not microsoft visual studio. So i
don't have access to those sorts of things.
Probably, you also don't have access to .NET, and you're therefore asking in the wrong 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 )
|
|
|
|
|
Thats annoying coz i really don't want to use the microsoft visual studio i have installed. Because then i would probably have to use .net and if i want to port to other platforms it would make it difficult.
|
|
|
|
|
I am assuming you downloaded an article here ? You need to ask on the forum for the article. Was it even written in C++/CLI ?
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 )
|
|
|
|
|
I am using Visual c++ Net 2005
How can I get System day or time ? and what namespace to use with it ?
|
|
|
|
|
Datetime structure will help you
|
|
|
|
|
System.DateTime.Now
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 )
|
|
|
|
|
have an application in visual c++ relating to client and server. this appliaction does many types of work like getting all user names logged on to computers,remote shutdown,remote logoff, getting the remote desktop view and many others types of functioning related to "lan monitoring" through server. but for this , client application has to be executed all the time whenever any user logon through his local account.
but the problem is that I couldn't find any way to execute the "client exe" automatically whenever any user logon through his/her local account.But I could execute the client exe automatically for the administrator by making changes in the registry but I have to execute it "for all users".
So please help me to find any way to execute the client exe for all users automatically whenever they logon through their local account.Is there any win api or by making any registry changes or any program which can call the exe automatically whenever any user login.
ps:since this is all a part of a domain so all the other users are less priviliged than admin
HELP HELP URGENT SITUATION
RAHUL CHHABRA
RAHUL CHHABRA
|
|
|
|
|
This is a .NET application ?
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 )
|
|
|
|
|
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 )
|
|
|
|