|
Please read the article:
http://www.codeproject.com/csharp/unmanage.asp
your problem will be done.
The Internet Give a Chance to Learn. I Do!
|
|
|
|
|
The first thing that I've made was read the article, It's a good article where I found how to avoid the problem of load the dll and the method but my actual problem is that I can load and detect the method but this don't return nothing. I don't know what it's happening.
|
|
|
|
|
If you want to return 'sText', you must ref the var.
Try this:
[DllImport("BabMD5.dll")] static extern long EncodeText(
string p_password,
ref string p_encText,
long p_size);
EncodeText("testestest",ref sText,33);
The Internet Give a Chance to Learn. I Do!
|
|
|
|
|
Good day. How do I send and receive WM_COPYDATA messages in C# that contain data? In particular, how do I unpack the COPYDATASTRUCT in C# when I get the WM_COPYDATA message? Sample code would be appreciated. Thanks Robert
|
|
|
|
|
I have a C# application, where I use a good old COM Object written in VC6. This is the easy part...
The COM Object implements Connection Points, to throw events to the client using it.
I can not get C# to catch those events. I have tried everything I can find in the documentation, but it don't work, the event-functions in C# is never called.
Anybody have a small sample of how to do this?
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
I have an exe-file and some .NET components (.dll) that the exe file uses. But when I try to start the exe file, I get the following error message. Does anybody know what to do here? Thanx,
ds
error message:
"class not registered."
========== Exception Text ==========
System.Runtime.InteropServices.COMException (0x80040154): class not registered
at System.Windows.Forms.AxHost.CreateInstance()
at System.Windows.Forms.AxHost.GetOcxCreate()
at System.Windows.Forms.AxHost.TransitionUpTo(Int32 state)
at System.Windows.Forms.AxHost.CreateHandle()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.AxHost.EndInit()
at VMS.ITFieldEditor.VDlgITFE.InitializeComponent()
at VMS.ITFieldEditor.VDlgITFE..ctor()
at VMS.ITFieldEditor.VITFieldEditor..ctor()
at VMS.ITFEBridge.VITFEBridge..ctor()
at TestDotnetApp.MainWin.btnStart_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
========== Loaded Assemblies ==========
mscorlib
Assembly Version: 1.0.2411.0
Win32 Version: 1.0.2914.16
CodeBase: file:///c:/windows/microsoft.net/framework/v1.0.2914/mscorlib.dll
----------------------------------------
TestDotnetApp
Assembly Version: 8.0.0.0
Win32 Version: 8.0.0.0
CodeBase: ...
----------------------------------------
System
Assembly Version: 1.0.2411.0
Win32 Version: 1.0.2914.16
CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v1.0.2914/System.dll
----------------------------------------
System.Drawing
Assembly Version: 1.0.2411.0
Win32 Version: 1.0.2914.16
CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v1.0.2914/System.Drawing.dll
----------------------------------------
System.Windows.Forms
Assembly Version: 1.0.2411.0
Win32 Version: 1.0.2914.16
CodeBase: file:///C:/WINDOWS/assembly/GAC/System.Windows.Forms/1.0.2411.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
ITFEBridge
Assembly Version: 8.0.0.0
Win32 Version: 8.0.0.0
CodeBase: ...
----------------------------------------
TestDotnetApp.resources
Assembly Version: 8.0.0.0
Win32 Version: 8.0.0.0
CodeBase:...
----------------------------------------
ITFieldEditor
Assembly Version: 8.0.0.0
Win32 Version: 8.0.0.0
CodeBase:...
----------------------------------------
CBase
Assembly Version: 8.0.0.0
Win32 Version: 8.0.0.0
CodeBase: ...
----------------------------------------
CFieldEditor
Assembly Version: 8.0.0.0
Win32 Version: 8.0.0.0
CodeBase: ...
----------------------------------------
CImageViewer
Assembly Version: 8.0.0.0
Win32 Version: 8.0.0.0
CodeBase: ...
----------------------------------------
AxCCOREVIEWERLib
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: ...
----------------------------------------
CCOREVIEWERLib
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: ....
----------------------------------------
CUIBase
Assembly Version: 1.0.657.22684
Win32 Version: 1.0.657.22684
CodeBase: ...
----------------------------------------
CVisUtils
Assembly Version: 8.0.0.0
Win32 Version: 8.0.0.0
CodeBase:...
----------------------------------------
ITFieldEditor.resources
Assembly Version: 8.0.0.0
Win32 Version: 8.0.0.0
CodeBase: ...
----------------------------------------
|
|
|
|
|
Did you register your dll?
Read this page..
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpapndx/html/_cor_deployment_and_configuration.asp
update: also this link.. depending on what you're doing..
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cptools/html/cpgrfassemblyregistrationtoolregasmexe.asp
|
|
|
|
|
i want to some code about sort files by it's type ,size etc
in listviewitem
thanks
|
|
|
|
|
Stipulation - I'm doing this with notepad and the SDK.. no Visual Studio.
How do you get a spawend dialog to interact with the main form? With VB, it was as easy as referring to the main form and it's properties. It doesn't seem to be as easy with c#.. example code..
<pre>
using System;
using System.Windows.Forms;
using System.Drawing;
class MainForm : Form {
Button btnGo = new Button();
public MainForm() {
Text = "Main Form";
btnGo.Location = new Point(100,100);
btnGo.Name = "btnGo";
btnGo.Text = "Go";
btnGo.Click += new EventHandler(btnGo_Click);
Controls.Add(btnGo);
Opacity = 80;
}
public static void Main(string[] args) {
Application.Run(new MainForm());
}
private void btnGo_Click( object sender, EventArgs e) {
Form2 x = new Form2();
x.ShowDialog();
}
}
class Form2 : Form {
Button btn1 = new Button();
public Form2() {
Text = "This is the second form";
btn1.Text = "Do it";
btn1.Location = new Point(100,100);
btn1.Click += new EventHandler(btn1_Click);
btn1.Name = "btn1";
}
private void btn1_Click(object sender, EventArgs e) {
//Here is where I want to modify the main form.
// How would I go about changing, let's say, the Title?
}
}
</pre>
|
|
|
|
|
Try this. I added 2 lines of code, one in the "Owner" form (btnGo_Click), and one in the "Owned" form (btn1_Click). Good Luck!
class MainForm : Form
{
 Button btnGo = new Button();
 public MainForm()
 {
  Text = "Main Form";
  btnGo.Location = new Point(100,100);
  btnGo.Name = "btnGo";
  btnGo.Text = "Go";
  btnGo.Click += new EventHandler(btnGo_Click);
  Controls.Add(btnGo);
  Opacity = 80;
 }
 public static void Main(string[] args)
 {
  Application.Run(new MainForm());
 }
 private void btnGo_Click( object sender, EventArgs e)
 {
  Form2 x = new Form2();
  x.Owner = this;
  x.ShowDialog();
 }
}
class Form2 : Form
{
 Button btn1 = new Button();
 public Form2()
 {
  Text = "This is the second form";
  btn1.Text = "Do it";
  btn1.Location = new Point(100,100);
  btn1.Click += new EventHandler(btn1_Click);
  btn1.Name = "btn1";
  Controls.Add(btn1);
 }
 private void btn1_Click(object sender, EventArgs e)
 {
  //Here is where I want to modify the main form.
  // How would I go about changing, let's say, the Title?
  this.Owner.Text = "HOWDY";
 }
}
Andy Gaskell, MCSD
|
|
|
|
|
Perfect! Except for the fact I didn't add the control.
Thanks...
|
|
|
|
|
In Java, you can create an instance of an object by name by getting the Class object by name, and then calling createInstance() - or something like that.
Is this possible in C#? It looks like I might be able to do it through assemblies, but I'm not sure.
Application: I want to be able to provide a configuration file that lists the class names of add-ins to load. The app would loop through these names, create instances and use them.
I know I can do it with COM, but I'd rather not subject the authors of add-ins to writing COM servers.
Anyways, is this possible?
J
|
|
|
|
|
You can use the Assembly class to load assemblies at runtime, the GetType function to get an object's type, and the Activator.CreateInstance static function to create an object of that type:
Assembly a = Assembly.Load("MyLibrary");
Type t = a.GetType("MyLibrary.MyClass");
object obj = Activator.CreateInstance(t);
cheers,
Chris Maunder (CodeProject)
|
|
|
|
|
How to search for files/folders and adding all the found filenames to a collection.
For exemple :
Search all "*.url" files on "C:"
Thanks
|
|
|
|
|
The things you need is located in the namespace System.IO... I would do it like this:
using System.IO;
public void FindFiles (string path)
{
if (Directory.Exists (path))
{
DirectoryInfo thisDir = new DirectoryInfo (path);
FileInfo [] files = thisDir.GetFiles ("*url");
DirectoryInfo [] subDirs = thisDir.GetDirectories ();
foreach (FileInfo f in files)
{
}
foreach (DirectoryInfo d in subDirs)
{
FindFiles (d.FullName);
}
}
}
Andreas Philipson
|
|
|
|
|
My boss says...
I need to create MS Word 97/2000 documents using C#.
In other words, we want to use MS Word to display the output from a C# program.
Things will change in the Word document like address, date, From, To and some accounting data pulled from our Oracle database.
Of course, I'm a 3 month newbie to .NET & C# programming.
Can anyone kick start me with some examples/code/book recommendations?
I've got my "Learn C# in 21 Days" book ordered...
-Larry
|
|
|
|
|
Basically, what you'll need to do is use the Word OLE interface from COM interop.
As a first step, in VS you add a reference to the word exe (I think) to your project, and that will give you a managed wrapper around the COM interfaces.
You can also do this from the command line with tlbimp.
|
|
|
|
|
Hi,
Does anyone know how to write a COM server in .Net?
// Christian
|
|
|
|
|
Create your .NET dll first
Now use regasm on it.
Now you can use this component using late binding
if you want early binding use tlbexp in it to generate a type library file
Nish
|
|
|
|
|
I'm looking for an example to create a out-of process local com server (.exe file)
// christian
|
|
|
|
|
I am programming using C# && .netframework(beta 2). now i have some problems about mdi application:
1: I create mdi child window based on System.Windows.Form. I want to show the child window with the main window. it have been created at Mainface.Mainface(); but i don't know where to load the Show() procedure;
2: I need to modify the system menu of child window, but how to get it's handle. In Win32, can use GetSystemMenu(), but in .netFramework there are no method like that.
3: Only set the Dock property of Form, the Form cannot dock properly in the main window. The phenomena is that when i create another mdi child window and maximize it , this window will cover the docked window. Why ?
The Internet Give a Chance to Learn. I Do!
|
|
|
|
|
hi, i just started to learn c++ at school. so this is a very newbie question...but how do u convert a char into an int??
|
|
|
|
|
This is the C# forum, not the C++. You should try and ask questions in the right place.
A char *is* an int, you can do this
char a = 65;
int i = 'A';
int z = 5;
z += a;
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
|
|
|
|
|
Ok, it depends on what you want to do though. Are you talking about having a character such as '4' which you want the value 4? Or are you talking about what the Graus-man said and want the ASCII value of the character?
Here is an example:
#include <stdio.h>
#include <stdlib.h>
void main( void )
{
char c = 'A';
char d = '4';
int i = 0;
printf( "Character '%c' is %d in ascii.\n", c, c );
printf( "Character '%c' is %d in ascii.\n", d, d );
printf( "Character '%c' is %d as an integer.\n", d, atoi( &d ) );
}
That yields the output :
Character 'A' is 65 in ascii.
Character '4' is 52 in ascii.
Character '4' is 4 as an integer.
I hope that helps you out!
----
Xian - www.hollowmedia.net
|
|
|
|
|
If is a char to int use that Christian Graus said but if String to int, you only need to use the atoi function...
Cheers
Carlos Antollini.
|
|
|
|