当使用QAxServer开发dll时,实际工程编译链接过程中会涉及到以下的过程:

  1. 应用程序将会链接到qtserver.lib而不是qtmain.lib
  2. idc工具会被调用,产生IDL文件(接口描述语言的接口描述文件)
  3. 调用MIDL工具编译IDL文件到类型库
  4. 调用idc工具将类型库附到server的二进制代码中
  5. 注册dll

.net 的工具
regasm.exe / tlb / codebase“ x64 ActiveX.dll的路径”

regsvr32 path\xxx.dll 安装
regsvr32 path\xxx.dll /u 卸载

阅读全文 »

QScopedPointer
QScopedArrayPointer

QScopedArrayPointer<unsigned char> buf_ptr(new unsigned char[RECV_BUF_MAX_SIZE]);

QSharedPointer

Qt内存自动释放有两个前提条件:
1. 必须是QObject的派生类
2. 必须指定了parent对象
即:Qt 中 父亲被删除的时候会自动销毁他的孩子。 所以。如果New出来的并且没有父亲。那么则需要手动删除它

QDialog 不能用 QSharedPointer 因为

MyDialog* d = new MyDialog(this);
d->exec();
ptrToSharedObj = d->objToShare();
// don't delete d explicitly, the QObject hierarchy will take care of that

TOML(Tom’s Obvious,Minimal Language)
TOML是由Tom - Tom Preston-Werner编写的 - 确切地说。这是一个在麻省理工学院授权的开源项目,目前在Github上有超过5k星。2013年3月发布的第一个TOML版本,使TOML成为三个标准的年轻人。

TOML的目标是成为最小的配置文件格式,由于精确的语义,这种格式易于阅读。TOML被设计为无歧义地映射到散列表。TOML应该很容易用各种语言来解析数据结构。

TOML区分大小写。
TOML文件只能包含UTF-8编码的Unicode字符。
空格表示制表符(0x09)或空格(0x20)。
换行符表示LF(0x0A)或CRLF(0x0D0A)。
要在前面的问题中使用TOML,你需要将它封装在+++如下之间

阅读全文 »

Cloning into ‘hugo-theme-learn’…
fatal: unable to access ‘https://github.com/matcornic/hugo-theme-learn.git/': OpenSSL SSL_connect: Connection was reset in connection to github.com:443

fatal: unable to access ‘https://github.com/matcornic/hugo-theme-learn.git/': Failed to connect to github.com port 443: Timed out

打开下面网址 把 ip 地址复制到 hosts 文件中
https://github.com.ipaddress.com/
https://fastly.net.ipaddress.com/github.global.ssl.fastly.net#ipinfo
https://github.com.ipaddress.com/assets-cdn.github.com

修改 hosts 文件,添加下面记录, ip 使用上面查询到的
112.64.186.254 github.com

修改完 hosts 文件后,刷新生效
ipconfig /flushdns

线程安全的容器

from queue import Queue

q = Queue()
for i in range(5):
q.put(i)

l = list(q.queue)
print(l)

# Output:
[0, 1, 2, 3, 4]

ARP协议是地址解析协议(Address Resolution Protocol)是通过解析IP地址得到MAC地址的

计算机中会维护一个ARP缓存表,这个表记录着IP地址与MAC地址的映射关系
ARP协议的主要工作就是建立、查询、更新、删除ARP表项。

查看列表

arp -a

转换 byte 数组 到 原始数据类型,比如 float, int


// 多线程使用 ConcurrentQueue
ConcurrentQueue<byte[]> que_sp = new ConcurrentQueue<byte[]>();

public void Task_SP()
{
byte[] datas = null;
while (FLAG_EXIT != (m_flag & FLAG_EXIT))
{
if (que_sp.TryDequeue(out datas))
{
siemensHelper.Write_bytes("DB.20.2075", ref datas, 47);
}else
{
Thread.Sleep(1);
}
}
}

界面常用控件

<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="35"></RowDefinition>
<RowDefinition Height="auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" Grid.Row="0" Margin="4">
<TextBlock VerticalAlignment="Center" Margin="4">资金总量:</TextBlock>
<TextBox x:Name="tb_cash_amount" VerticalContentAlignment="Center" Margin="4,0" Width="80" Height="25"></TextBox>
<ComboBox x:Name="cmb_investment_percent" Margin="4,0" Height="25" VerticalContentAlignment="Center">
<ComboBoxItem IsSelected="True">10%</ComboBoxItem>
<ComboBoxItem >20%</ComboBoxItem>
<ComboBoxItem >30%</ComboBoxItem>
<ComboBoxItem >40%</ComboBoxItem>
<ComboBoxItem >50%</ComboBoxItem>
</ComboBox>
<TextBlock VerticalAlignment="Center" Margin="4">建议使用资金量:</TextBlock>
<TextBox x:Name="tb_investment_amount" VerticalContentAlignment="Center" Margin="4,0" Width="80" Height="25"></TextBox>

<Button x:Name="btn_calc" Click="btn_import_record_Click" Margin="4,0">计算</Button>
</StackPanel>
<TextBlock Grid.Row="1" x:Name="tbl_state" Visibility="Collapsed">状态:</TextBlock>
<DataGrid Name="dg" Grid.Row="2" AutoGenerateColumns="False" IsReadOnly="True" CanUserSortColumns="True" CanUserAddRows="False">
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding RecordDateTime, UpdateSourceTrigger=PropertyChanged }" Width="130" Header="时间"/>
<DataGridTextColumn Binding="{Binding Info, UpdateSourceTrigger=PropertyChanged}" Width="*" Header="内容"/>
</DataGrid.Columns>
</DataGrid>
</Grid>

SymChk 在线的目录下
C:\Program Files (x86)\Windows Kits\10\Debuggers\x64

生产下载清单
SymChk /om c:\Manifest\man.txt /ie yourApp.exe

下载符号文件 c:\mysymbols 目录下
SymChk /im c:\FolderOnOtherComputer\man.txt /s srvc:\mysymbols\aServer\symbols