|
Please don't write in bold.
You can use 2.0 code in 1.*
search tjis forum for a solution on how to use VS2005 with 1.1
--------------------------------------------------------
My development blog
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
sorry CWIZO.. i corrected the text .. thanks.
|
|
|
|
|
Ooops what I was trying to say before is that you can't use .NET 2.0 code in visual studio 2003. VS2003 just dosen't work with .NET 2.0
--------------------------------------------------------
My development blog
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
INPUT :
VC++ dll (abcd.dll) has funtion named DecryptString.
Requirement :
i need to create a dotnet project which uses this function in unmanaged dll.
Steps taken
public class CryptoAPI
{
[DllImport("abcd.dll", EntryPoint="#392")]
public static extern string DecryptString(string key,string text);
}
When i access the function in DOTNET
string EncryptedText = CryptoAPI.DecryptString(Key,PlainText);
It works fine couple of times.Some times it throws up an error
"object reference not set to instance of an object".
Can u please help me on this?
Can u tell me if i call the method - 5 times is it loaded 5 times during the runtime?
or only once when i do it for the first time.
for thendral
|
|
|
|
|
Maybe you pass to your function null or empty string ?
Try to check this before call.
I use this function: string.IsNullOrEmpty(string)
|
|
|
|
|
I have validated the function before.
The gets passed the unmanaged code as well the unmanaged code returns a value
but the result set is not recieved back in the DOTNET string.
getting me?
string EncryptedText = CryptoAPI.EncryptCString (Key,PlainText);
VC++ implementation()
{
char * EncryptCString (Key,PlainText);
{
AfxMessageBox(Key);
AfxMessageBox(PlainText);
///Code to do manipulatione
AfxMessageBox(encryptedvalue);
return encryptedvalue
}
}
the above code snippet ensure that the values of the parameter are passed correctly to the
unmanaged code and it process and return the value correctly
so the interop is the problem i suppose?
ie) getting it from vc++ to DOTNET ?
for thendral
|
|
|
|
|
Try to set charset in DllImport attribute:
<br />
[DllImport("abcd.dll", CharSet=CharSet.Ansi, EntryPoint="#392")]<br />
public static extern string DecryptString(string key,string text);<br />
And try unmanaged type conversions:
<br />
[DllImport("abcd.dll", EntryPoint="#392")]<br />
public static extern [MarshalAs(UnmanagedType.LPStr)] string DecryptString(string key,string text);<br />
I don't know exactly wich type is char *.
I hope you'll find it changing UnmanagedType.LPStr to other string types from UnmanagedType enum.
|
|
|
|
|
I had a similar function that returned a string from a C++ dll. Try declaring a global char array in your dll and then copy the string into the array, as below:
char szReturn[MAX_PATH];<br />
<br />
BOOL APIENTRY DllMain( HANDLE hModule, <br />
DWORD ul_reason_for_call, <br />
LPVOID lpReserved<br />
)<br />
{<br />
return TRUE;<br />
}<br />
<br />
__declspec(dllexport) LPCTSTR Test()<br />
{<br />
<br />
lstrcpy(szReturn,"success!");<br />
return szReturn;<br />
}
Hope that helps
|
|
|
|
|
When, if ever, should we force the garbage collection to run??
|
|
|
|
|
why all messages are not in one... dont flood
|
|
|
|
|
Different questions - Different posts. If he wrote better subject lines it would work better. Also, if you put in all your questions into one post some people feel reluctant to answer because they don't know the answer to all the questions, or they may feel compelled to answer a post that is beyond their knowledge and give the OP some bad advice.
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|
|
Please don't cross post.
Please don't spam the forum.
pankajgarg12 wrote: When, if ever, should we force the garbage collection to run?
Normally never. The garbage collection runs when needed and when there is enough unused objects for a collection to be effective. Unless you have a very extreme situation you never have to bother about it.
---
b { font-weight: normal; }
-- modified at 5:03 Wednesday 12th April, 2006
|
|
|
|
|
Everything on this forum is a problem to someone - A subject line of "problem" is absolutely useless. Please read the post at the top of the group by Chris that explains the rules of the foru,.
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|
|
Why should we not use global variables??
|
|
|
|
|
Please don't cross post.
Please don't spam the forum.
pankajgarg12 wrote: Why should we not use global variables?
Because the code gets hard to follow. If you use global variables you have to know how the entire application is working to know how the global variables are used.
---
b { font-weight: normal; }
-- modified at 5:03 Wednesday 12th April, 2006
|
|
|
|
|
What is the difference b/w class and module??
|
|
|
|
|
Class is an instrument of object oriented programming.
Module is only file. wich can contain classes.
Module can contain several classes.
You'll learn more, after reading book about C# or object oriented programming.
|
|
|
|
|
Please don't cross post.
Please don't spam the forum.
---
b { font-weight: normal; }
|
|
|
|
|
Hello
I've got an idea of a ContextMenu containing special MenuItem's. I've spent the last hours with codeproject, google and a lot of coffee, but I can't find an answer. Perhaps it is very very simple and I'm just too stupid for a clear solution or otherwise it's not possible without writing a complete own implementation of a ContextMenu-class !?
ok, here you are :
I want to develop a 'customMenuItem'-class that can hold 3 or more icons/buttons (play, stop, continue) and a text entry, everything else should act as usual. I want to set a handler to each of the icons/buttons not to the text. I got no prob's with displaying my Items, but I don't found a way to set this kind of hanld or to decide on which button or Icon I've clicked (tryed with some x-positions-attributes).
ok, thanks for reading, but please do not answer with articles like 'how to build menu's with icons', they do not have different handlers for one item or don't analyse any kind of x-position inside.
thx's a lot for reading - sorry for my poor english
Mark Nüßler
|
|
|
|
|
Play, pause, continue....
You can dynamicaly uptate one item, because when one of them enabled - other items disabled, why do you want to display them all ?
|
|
|
|
|
mh,
you are right - my example with 'play, pause, continue' is not the best. just imagine some more states or actions, that do not exclude each other.
thanks for reading my question and your fast answer
|
|
|
|
|
nuessler wrote: just imagine some more states or actions, that do not exclude each other.
I think that MenuItem designed for single action.
Try using standart controls such as toolbar.
Or design "floating toolbar".
|
|
|
|
|
Hehe... Sounds like a very interesting problem...
I've done some stuff that's kinda similar, but means overriding the OnPaint method... You could always dynamically position your control according to the MouseClick event...
On_MouseClick(object sender, MouseEventArgs e){
if(e.MouseButton == MouseKeys.Right){
HoverControl control = new HoverControl();
control.Location = new Point(e.Point);
control.Show();
}
}
(Just typed that by hand... It's close, but capitalization and names might be off...)
Handle the closing of the control in the control. If you're working with a grid, you could use the object you've got in the selected row of the grid, and if no item selected, don't show the control.
Hope this helps...
F~
|
|
|
|
|
Hi,
I'm a newbie in C#! Now, I want to start my application when Windows (XP SP2) starts.
How can I do?
Thanks,
Hung
-- modified at 0:13 Wednesday 12th April, 2006
|
|
|
|
|
Add link to exe file into Windows menu "Programs\StartUp" or
add key MyProgram = "c:\MyProgram\MyProgramm.exe" into registry path "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run"
(if you need to run program once add to path "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce")
|
|
|
|