|
|
I have read about how to send parameters to an application at runtime but what if the program is all ready running? Here is where I am stuck...
1. Run my application to get it into taskbar.
2. Click on a special hyperlink to send a parameter to this application.
I have learned how to create a registry entry to launch my application when a link is launched. Here are the problems..
1. I don't want my app to run again if the link is clicked again.
2. I need to link to continue to get parameters as the links get clicked
Any help here would be great.
|
|
|
|
|
|
Hi..
I have a vc++ dll that returns a Bstr that i need to read out in c# the dll is called like (at the moment)
[DllImport("myDLL.dll")]
[return : MarshalAs(UnmanagedType.BStr)]
private static extern string Getbstr();
i have tryed
string tmp = Marshal.PtrToStringBSTR(Getbstr());
pvarData="02" + tmp;
etc.. but only seam to get garbage.. can anyone help me or point me to a web site that explains the formats bstr etc...or how to convert them.
many thanks
calvin
P.S please be kind i have only just learnt c++ and the dll returns a bstr as it is also shared with vb apps...
|
|
|
|
|
Calvin Streeting wrote: [DllImport("myDLL.dll")]
[return : MarshalAs(UnmanagedType.BStr)]
private static extern string Getbstr();
Where did you get your import statement from?
led mike
|
|
|
|
|
the dll is declared as in vc6++
MYDLL_API BSTR __stdcall getbstr();
So i googled and people were mentioning "MarshalAs" which seameed to complie fine, is there another way (hopefully without changing the dll)
many thanks
calvin
|
|
|
|
|
Calvin Streeting wrote: the dll is declared as in vc6++
MYDLL_API BSTR __stdcall getbstr();
So the C module is allocating the BSTR. How is the deallocation handled?
Calvin Streeting wrote: have tryed
string tmp = Marshal.PtrToStringBSTR(Getbstr());
Did you try
string tmp = Getbstr();
led mike
|
|
|
|
|
Hi... I think i got it now..
here is a more complete code...
vc++ dll
//----------------------------------------------
//header
SSFILEDLL_API BSTR __stdcall GetEmailSubject();
SSFILEDLL_API BSTR __stdcall GetEmailData(char *szString);
//----------------------------------------------
//code
SSFILEDLL_API BSTR __stdcall GetEmailSubject(){
return GetEmailData("__substg1.0_0037001E");
}
SSFILEDLL_API BSTR __stdcall GetEmailData(char *szString){
BSTR Message;
COleStreamFile osf;
if (myCSS.OpenStream(szString, osf)) {
DWORD dwLength = osf.GetLength();
LPSTR buffer=(LPSTR)_alloca(dwLength+1);
osf.Read(buffer,dwLength);
buffer[dwLength]='\0';
Message = SysAllocStringByteLen(buffer, lstrlen(buffer));
return Message;
}
else {
char *buff = "False";
Message = SysAllocStringByteLen(buff, lstrlen(buff));
return Message;
}
}
and then in c#
I used
//----------------------------------------------
//header
[DllImport("ssFileDLL.dll")]
private static extern IntPtr GetEmailSubject();
IntPtr ptr = GetEmailSubject();
string s = Marshal.PtrToStringAnsi(ptr);
if (s!="False")
pvarData="" + s;
else
pvarData="";
and that seems to work... the code is a two part affair.. the first vc++ dll deals with outlook msg files parsing them and getting the mapi properties...
the second part is a explorer shell extention that shows the mapi properties for folders that contain archived (saved out of outlook) folders containing msg files...
after a bit of frigging around i now have form,to,subject,attachment count, and i am working on the sent/recived date... that are returned as a FILETIME
so onward i march and many thanks for your help...
calvin
ps any comments on code are always apreciated as i am new to the language (vb is far mote forgiving than c,c#,c++ etc...)
|
|
|
|
|
Calvin Streeting wrote: here is a more complete code...
If you have the source code for the DLL why don't you create a C++/CLI mixed mode managed assembly that exposes a .NET class and encapsulates all the native to managed activities?
led mike
|
|
|
|
|
Ok.... back to google to learn what all that means ...
Many thanks
Calvin...
|
|
|
|
|
We have some great introductory articles here on CodeProject written by Nishant Sivakumar. In the site menu on the side of the page under "Chapters", click "Languages" and then click "C++ / CLI"
led mike
|
|
|
|
|
Is there any difference between the two? I couldn't find simple tutorial Thanks
|
|
|
|
|
Sections 1.6.7.4 and 10.8 of the C# spec cover events.
An event is basically a property whose type is a delegate.
|
|
|
|
|
hi
in my main app, i was set app icon, then create new solution (setup application), and add my app files to it, and build my setup app, but when i test setup app, my app icon lost in exe file, why and how to solve my problem ?
thanks.
|
|
|
|
|
I have had this issue in the past as well. What I did is I added the icon to the resources directory of the project, then set the icon to be included as CONTENT in the resulting exe (through the properties window). Then use this icon (the one in the resources directory) as the one for the project. Be sure that if you want to use this icon on shortcuts that you include it in the application directory, and set the Icon property of the shortcuts to be the icon in that directory. Let me know if I need to explain this any more.
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
thanks for reply
do your intent is that i must add my icon to resource directory of my main app and in my solution, set build action to embedded as resource in properties window ?
thanks
|
|
|
|
|
I don't think it matters if it is in the resource directory or not, but yes, I do think that you either must copy it to the output directory or use it as embedded content. Otherwise, for some reason installing through setup does not maintain the image.
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
thanks for reply
but when i use installShield, it is make setup without any problem!
|
|
|
|
|
I'm glad you got it working.
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
Hi all,
I've got a System.Version field which I'm accessing from a property thusly:
[XmlRootAttribute(ElementName="quote", IsNullable=false)]
public class QuoteData
{
[XmlAttributeAttribute( DataType = "dll_version" )]
public Version DLLVersion
{
get
{
return dllVersion;
}
set
{
dllVersion = value;
}
}
private Version dllVersion = new Version();
}
but when I try to serialize it I get the error: "There was an error reflecting property DLLVersion". Any suggestions as to what's causing the error?
TIA.
|
|
|
|
|
hey guys, got a problem over here which i cant seem to solve. i have 1 picturebox displaying an image, and the second thats drawn on top of it, does not allow the bottom one to show through. what can be done to resolve this. will i have to resort to drawing my complex shapes with gdi?
|
|
|
|
|
There is no dilemma, whenever you are not sure a PictureBox can do what you want, well it can't.
what magic is it you expect a PictureBox to offer? it is a rather stupid Control, often not worth
the trouble. If you need more than just show a single Image, forget about a PictureBox, and
paint/draw whatever it is you need on your Form or on a Panel directly.
Yes, that takes GDI+ to do it, but then you get what you want, without disappointments.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Hi,
I have developed a code to write into a .csv file with comma delimiter.
Not sure why I do not get each recor into one complete line.
At present, the first three fields appear in row 1, then the next few into row 2 and some in column 3...
Not sure what I am doing wrong.
Thanks
StreamWriter textOut =
new StreamWriter(
new FileStream(path, FileMode.Create, FileAccess.Write));
for each record
textOut.Write(SecurityPricing.Security_ID + ",");
textOut.Write(SecurityPricing.Security_Name + ",");
textOut.WriteLine(SecurityPricing.Bid_Source + ",");
...
...
...
|
|
|
|
|
arkiboys wrote: Not sure what I am doing wrong.
This is happening because you are writing one column at a time to your file. You need to be writing one row at a time. This example loops through the rows of a table, then loops through the columns, adds the value to a string, and tacks on a comma at the end, then goes to the next. When it is done with all the columns in a row, it writes the row to the file, and moves on to the next. Hope this helps.
for (int r = 0; r < someTable.Rows.Count; r++)
{
for (int c = 0; c < sometable.Columns.Count; c++)
{
strWriteText += string.Format("{0},", someTable[r][c].ToString());
}
File.AppendAllText(strFilePath, string.Format("{0}{1}", strWriteText, Environment.NewLine), Encoding.UTF8);
strWriteText = string.Empty;
}
I'm going to become rich when I create a device that allows me to punch people in the face over the internet.
"If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
|
|
|
|
|
I do not get one column per row. As explained, I get the first three fields in the first row, then each column in a separate row.
This is what I have in case you spot anything. Thanks
public static void SavePrices(List<clsSecurityPricing> securities)
{
// if the directory doesn't exist, create it
if (!Directory.Exists(dir))
Directory.CreateDirectory(dir);
// create the output stream for a text file
StreamWriter textOut =
new StreamWriter(
new FileStream(path, FileMode.Create, FileAccess.Write));
// write each Security Price...
foreach (clsSecurityPricing SecurityPricing in securities)
{
textOut.Write(SecurityPricing.Security_ID + ",");
textOut.Write(SecurityPricing.Security_Name + ",");
textOut.WriteLine(SecurityPricing.Bid_Source + ",");
textOut.WriteLine(SecurityPricing.Bid_Size_Best_Latest + ",");
textOut.WriteLine(SecurityPricing.Bid_Price_Best_Latest + ",");
textOut.WriteLine(SecurityPricing.Ask_Price_Best_Latest + ",");
textOut.WriteLine(SecurityPricing.Ask_Size_Best_Latest + ",");
textOut.WriteLine(SecurityPricing.Ask_Source + ",");
textOut.WriteLine(SecurityPricing.Bid_Price_Best_AllDay + ",");
textOut.WriteLine(SecurityPricing.Ask_Price_Best_AllDay);
}
// write the end of the document
textOut.Close();
}
|
|
|
|