extern

C#调用Win32 的API函数--User32.dll ----转载

纵饮孤独 提交于 2019-12-26 17:15:37
Win32的API函数是微软自己的东西,可以直接在C#中直接调用,在做WinForm时还是很有帮助的。有时候我们之直接调用Win32 的API,可以很高效的实现想要的效果。 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Runtime.InteropServices; namespace WindowsAPI { class CSharp_Win32Api { #region User32.dll 函数 /// <summary> /// 该函数检索一指定窗口的客户区域或整个屏幕的显示设备上下文环境的句柄,以后可以在GDI函数中使用该句柄来在设备上下文环境中绘图。hWnd:设备上下文环境被检索的窗口的句柄 /// </summary> [DllImport("user32.dll", CharSet = CharSet.Auto)] public static extern IntPtr GetDC(IntPtr hWnd); /// <summary> /// 函数释放设备上下文环境(DC)供其他应用程序使用。 /// </summary> public static extern int ReleaseDC(IntPtr

关于使用条码打印机指令打印汉字的问题

回眸只為那壹抹淺笑 提交于 2019-12-26 11:03:03
最近公司做项目,用到条码,对于打印机来说很简单的啦,直接编辑文本输出不就可以打印了吗,是的,但是有时候,要打印的内容是动态的,需要制作条码的软件来完成有点不切实际。大多数的条码打印机是不支持用指令直接打印汉字的。 网上找了好多,唯一可行的就是调用第三方dll来完成,这样把要打印的汉字根据第三方的dll进行转换,得到了条码打印机ZPL自己识别的语言。就可行了。 我用的是斑马GK888T打印机。fnthex32.dll [DllImport("fnthex32.dll")] public static extern int GETFONTHEX( string BarcodeText, string FontName, string FileName, int Orient, int Height, int Width, int IsBold, int IsItalic, StringBuilder ReturnBarcodeCMD); 有个类BarcodePrint using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; namespace Barcode { class BarcodePrint { [System.Runtime

AnyQ搭建与编译问题解决

浪尽此生 提交于 2019-12-26 04:33:11
AnyQ 搭建过程与编译问题解决 写在最前:之前工程上使用过anyq,搭建过程尤其不顺利,现在之前的方法和经验重新搭建,发现竟然搭建不起来,所以按照官方的文档,重新的尝试,总结出几点常见的问题和解决方法。 搭建过程参考我之前的博客 搭建AnyQ方法 基本的步骤和过程没有问题,但是安装现有的docker 和 github,是编译不成功的。 常见问题 1. docker run docker run -dit -p 0.0.0.0:9999:8999 paddlepaddle/paddle:latest-dev 修改成 docker run -dit -p 9999:8999 paddlepaddle/paddle:latest-dev /bin/bash 原方法会出现一run 不起 docker docker ps 时什么都没有 docker ps -a 时发现,容器退出了。 2. make 报错 [ 4%] Built target extern_leveldb [ 9%] Built target extern_jsoncpp [ 13%] Built target extern_gtest [ 18%] Built target extern_xgboost [ 22%] Built target extern_eigen [ 26%] Built target extern

void,extern,sizeof

左心房为你撑大大i 提交于 2019-12-25 18:33:37
高手潜规则:禁用 goto 程序质量与 goto 出现次数成反比 void 指针的意义 1.C 语言规定只有相同类型的指针才可以相互赋值 2.void* 指针作为坐值用于“接收”任意类型的指针 3.void* 指针作为右值赋给其它指针时需要强制转换类型。 int *pI = (int*)malloc(sizeof(int)); extern 的意义 1. 用于声明外部定义的变量和函数 2. 用于 “告诉”编译器用 C 方式编译 C++ 编译器和一些变种 C 编译器默认会按自己的方式编译函数和变量,所以有事需要 extern 关键字。 extrn “C” { int f(int a,int b) { return a+b; } } sizeof 是编译器内置指示符,不是函数。 用法: 用了统一, sizeof(int) ,不推荐用空格。 来源: https://www.cnblogs.com/stm32f4/p/6264765.html

Call C++ Exported Function in C# [closed]

断了今生、忘了曾经 提交于 2019-12-25 09:08:42
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . I have the following C++ code: #pragma once #include "StdAfx.h" #include <string> using namespace std; using namespace System; extern "C" __declspec( dllexport ) string __stdcall GetVale() { return "test"; } I am

信号量与互斥锁

故事扮演 提交于 2019-12-25 03:01:19
学习Mutex的心得,不一定对,先记录一下。 同步技术分为两大类,锁定和信号同步。 锁定分为:Lock、Monitor 信号同步分为:AutoResetEvent、ManualResetEvent、Semaphore以及Mutex。他们都继承自WaitHandle, AutoResetEvent、ManualResetEvent在内存中维护一个布尔型变量,如果为false则阻塞,如果为true则解除阻塞 Semaphore在内存中维护一个整型变量,如果为0则阻塞,如果大于0则解除阻塞,每解除一个阻塞其值减一 AutoResetEvent、ManualResetEvent、Semaph提供单进程内的线程同步 Mutex提供跨应用程序域的线程阻塞和解除的能力,主要用于互斥访问。 下面是一个使用Mutex进行互斥访问的演示例子。 软件打开时,如果接收到输入则创建一个互斥锁,并持有锁,直到再次接收到输入,然后释放锁,如果再次输入又创建锁, 如此循环。 假设app1创建一个互斥锁,然后持有锁,并对共享资源进行操作,那么app2就不能再次创建互斥锁,据此就能判断共享资源释放被别的进程占用。 如果app1使用完了共享资源,释放了互斥锁,则app2就可以创建互斥锁,据此可以判断共享资源可以被访问了。 以下是app1代码 1、Mutex用于进程间的同步 using System; using

Use variable across multiple Cpp files

﹥>﹥吖頭↗ 提交于 2019-12-24 18:12:58
问题 Have searched enough answers but none of the solutions work for me. scenario : I am trying to include a .h file that has some functions declared (not defined) and some variables declared. If I include this header file in the source files (2 to be precise) that actually use the functions and variables, then the last one that compiles has a linker error that states undefined reference to `abc::myfun(char const*, char const*, char*)' All the functions and variables in the header files have been

sizeof(extern类型数组)

倖福魔咒の 提交于 2019-12-24 13:59:55
error: #70: incomplete type is not allowed 用sizeof计算数组大小,编译器提示不允许使用不完整的类型。在keil上编译直接报错,拿到vs2010上编译可以通过,但是结果始终为0. 折腾半天终于搞明白其中的原因,原因如下:   1.sizeof的计算发生在代码编译的时候;   2.extern是在链接的时候解析的。 所以extern数组的时候,在.C文件里面只知道有这么个东西,但是具体长啥样不知道,只有到链接的时候才能确定其大小。sizeof在编译的时候extern数组还没有链接,所以才会提示不允许使用不完整的类型。 解决方法:1.直接把变量定义在要用sizeof的文件中。      2.定义一个数组大小的宏。 来源: https://www.cnblogs.com/huhui/p/6913582.html

How can we share a Hash table between two different kernel modules

假装没事ソ 提交于 2019-12-24 13:53:07
问题 Is it possible to share a Hash_table defined in one kernel module in another kernel module. /*Hash table declarartion and definition*/ DEFINE_HASHTABLE(my_hash_table, HASH_TABLE_BITS); I am populating this table in one module, however I would like to access this table in another module as well. Does extern declaration work here. extern DEFINE_HASHTABLE(...,...) 回答1: DEFINE_HASHTABLE is variable's definition . For declare variable (without defining it) use DECLARE_HASHTABLE : extern DECLARE

C++ extern function error: too many arguments to function

瘦欲@ 提交于 2019-12-24 09:27:34
问题 I have a cw.h file with a bunch of extern functions in it that I want to call from my cw.cpp file. They are expressed like this in the .h . file along with the declarations of the Type struct (just example functions, not the actual names of the functions): extern Type* new_type(), match(), sharetype(); But their definitions and implementations are in the cw.cpp file. Each of the functions has 1 or more parameters passed into it. When I try compiling, I keep getting this error message for each