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);
}

谢谢!
...全文
1574 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;


【为什么还需要学习C++?】 你是否接触很多语言,但从来没有了解过编程语言的本质?你是否想成为一名资深开发人员,想开发别人做不了的高性能程序?你是否经常想要窥探大型企业级开发工程的思路,但苦于没有基础只能望洋兴叹? 那么C++就是你个人能力提升,职业之路进阶的不二之选。【课程特色】 1.课程共19大章节,239课时内容,涵盖数据结构、函数、类、指针、标准库全部知识体系。2.带你从知识与思想的层面从0构建C++知识框架,分析大型项目实践思路,为你打下坚实的基础。3.李宁老师结合4大国外顶级C++著作的精华为大家推出的《征服C++11》课程。【学完后我将达到什么水平?】 1.对C++的各个知识能够熟练配置、开发、部署;2.吊打一切关于C++的笔试面试题;3.面向物联网的“嵌入式”和面向大型化的“分布式”开发,掌握职业钥匙,把握行业先机。【面向人群】 1.希望一站式快速入门的C++初学者; 2.希望快速学习 C++、掌握编程要义、修炼内功的开发者; 3.有志于挑战更高级的开发项目,成为资深开发的工程师。 【课程设计】 本课程包含3大模块基础篇本篇主要讲解c++的基础概念,包含数据类型、运算符等基本语法,数组、指针、字符串等基本词法,循环、函数、类等基本句法等。进阶篇本篇主要讲解编程常用的一些技能,包含类的高级技术、类的继承、编译链接和命名空间等。提升篇:本篇可以帮助学员更加高效的进行c++开发,其包含类型转换、文件操作、异常处理、代码重用等内容。

110,533

社区成员

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

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

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