C++中的void * == C#中的什么?

cident 2005-01-27 09:26:01
[DllImport("ImageConv.dll", EntryPoint = "SetImageConvCallbackFunc")]
public static extern void SetImageConvCallbackFunc(void *pFuncCallbackProc);


还有C++中这样的一个全局函数,C#(VS2005 Beta)中怎么表示呢?在哪里表示?
// error handlers
void ImageConv_Callback_Handler(const char *szInfo)
{
AfxMessageBox(szInfo);
}

谢谢!
...全文
1577 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
boytomato 2005-01-28
  • 打赏
  • 举报
回复
using System;

namespace ConsoleApplication2
{
/// <summary>
/// Class1 的摘要说明。
/// </summary>
class Class1
{

enum Days {Sat, Sun, Mon, Tue, Wed, Thu, Fri};


/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: 在此处添加代码以启动应用程序
//

Console.WriteLine("Sun = {0}", Days.Sun.ToString ());

Console.Read ();



}
}
}
boytomato 2005-01-28
  • 打赏
  • 举报
回复
enum SRC_IMAGE_TYPE {
IMAGE_TYPE_UNKNOWN,
IMAGE_TYPE_BMP,
IMAGE_TYPE_JPG,
IMAGE_TYPE_GIF,
IMAGE_TYPE_TIFF,
IMAGE_TYPE_PNG,
};
?中的类型进行比较还是??
cident 2005-01-28
  • 打赏
  • 举报
回复
那么怎么比较呢?就是类似CompareNoCase那种?
yzgnick 2005-01-28
  • 打赏
  • 举报
回复
up
boytomato 2005-01-28
  • 打赏
  • 举报
回复
this.textBox3 .Text=this.openFileDialog1 .FileName .Substring(this.openFileDialog1 .FileName.Length-3,3);
返回你要的那种格式....
boytomato 2005-01-28
  • 打赏
  • 举报
回复
这样返回的是是 .jpg, .bmp等格式..你可以处理字符串得到最后三个字符就是文件扩展名...
boytomato 2005-01-28
  • 打赏
  • 举报
回复
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace WindowsApplication1
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.OpenFileDialog openFileDialog1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.TextBox textBox2;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;

public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();

//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}

/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
this.textBox1 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.textBox2 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(208, 104);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(72, 21);
this.textBox1.TabIndex = 0;
this.textBox1.Text = "textBox1";
//
// button1
//
this.button1.Location = new System.Drawing.Point(160, 160);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(64, 24);
this.button1.TabIndex = 1;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(208, 64);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(72, 21);
this.textBox2.TabIndex = 2;
this.textBox2.Text = "textBox2";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.button1);
this.Controls.Add(this.textBox1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);

}
#endregion

/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}

private void Form1_Load(object sender, System.EventArgs e)
{

}

private void button1_Click(object sender, System.EventArgs e)
{
if (this.openFileDialog1 .ShowDialog()==DialogResult.OK )
{
this.textBox1 .Text=this.openFileDialog1 .FileName;
this.textBox2 .Text=System.IO .Path.GetExtension(this.openFileDialog1.FileName);
}
}
}
}
cident 2005-01-27
  • 打赏
  • 举报
回复
OpenFileDialog fdlg = new OpenFileDialog();
fdlg.Title = "C# Corner Open File Dialog";
fdlg.InitialDirectory = @"c:\";
fdlg.Filter =
"BMP Files (*.bmp)|*.bmp|JPG Files (*.jpg)|*.jpg|GIF Files (*.gif)|*.gif|TIFF Files (*.tiff)|*.tiff|PNG Files (*.png)|*.png|All Files (*.*)|*.*||";

fdlg.FilterIndex = 2;
fdlg.RestoreDirectory = true;
if (fdlg.ShowDialog() == DialogResult.OK)
{
textBox1.Text = fdlg.FileName;

string strFileExternalname = fdlg.FileName;

怎么根据上面的代码获取文件的格式呢?就是知道是"bmp"还是"jpg"呢?
cident 2005-01-27
  • 打赏
  • 举报
回复
我的是函数指针啊!
string == const char *的。
sutalon 2005-01-27
  • 打赏
  • 举报
回复
c++ 中的 void 在c# 中也用 void 来表示了
boytomato 2005-01-27
  • 打赏
  • 举报
回复
类的变量,直接命名就行了.

c#也支持
enum 类型数据的...

你要是原来的程序中有函数指针
在 c#中可以用委托解决.....
boytomato 2005-01-27
  • 打赏
  • 举报
回复
c#中的数据类型如何与API中的类型定义对应!
Wtypes.h 中的非托管类型 非托管C 语言类型 托管类名 说明
HANDLE void* System.IntPtr 32 位
BYTE unsigned char System.Byte 8 位
SHORT short System.Int16 16 位
WORD unsigned short System.UInt16 16 位
INT int System.Int32 32 位
UINT unsigned int System.UInt32 32 位
LONG long System.Int32 32 位
BOOL long System.Int32 32 位
DWORD unsigned long System.UInt32 32 位
ULONG unsigned long System.UInt32 32 位
CHAR char System.Char 用 ANSI 修饰。
LPSTR char* System.String 或 System.StringBuilder 用 ANSI 修饰。
LPCSTR Const char* System.String 或 System.StringBuilder 用 ANSI 修饰。
LPWSTR wchar_t* System.String 或 System.StringBuilder 用 Unicode 修饰。
LPCWSTR Const wchar_t* System.String 或 System.StringBuilder 用 Unicode 修饰。
FLOAT Float System.Single 32 位
DOUBLE Double System.Double 64 位
cident 2005-01-27
  • 打赏
  • 举报
回复
还有,我怎么在一个类中声明变量呢?
BOOL m_bIsI860ExternalImage;

enum SRC_IMAGE_TYPE {
IMAGE_TYPE_UNKNOWN,
IMAGE_TYPE_BMP,
IMAGE_TYPE_JPG,
IMAGE_TYPE_GIF,
IMAGE_TYPE_TIFF,
IMAGE_TYPE_PNG,
};

SRC_IMAGE_TYPE m_eSrcImageType;


110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧