共享数据段的设置

一般来说,动态链接库在内存中只会加载一次
每个进程需要调用到次动态链接库的时候,都会从这一个内存地址中加载
但,如果进程需要改动动态链接库中的信息,哪怕是全局变量,系统也会从内存中重新分配出一小块区域,来进行这些变量的存储
那么与之对应的,每一个进程,所修改的动态链接库,只能是自己的一份,不能在所有进程中共享的
如果想在所有进程中共享一份动态链接库数据,则需要在DLL中设置一个共享的 “段”。
以下代码是定义一个节并给节命名为MySec,HWND g_hWnd=NULL;为将放在节中的数据

#pragma data_seg("MySec")
HWND g_hWnd=NULL;
#pragma data_seg()

注意:但是放在 MySec 段中的变量必须要被初始化。飞走而编译器就会将该变量放到 MySec 段以外
的其他段中。

仅定义一个数据段还不能达到共享数据的目的,还要告诉编译器该段的属性,有两种方法可以实现该目的(其效果是相同的),一种方法是在.DEF文件中加入如下语句:

SETCTIONS
  MySec READ WRITE SHARED

另一种方法是在项目设置链接选项中加入如下语句:

/SECTION:shareddata,rws

RWS:r为读,w为写,s为共享

或者 使用一种更方便的方法,直接将连接器开关嵌入到 dll 的源代码中。

#pragma comment(linker,"/section:MySec,RWS")

pycharm5.0 激活

1

0x1 ,安装
0x2 , 调整时间到2038年。
0x3 ,申请30天试用
0x4, 退出pycharm
0x5, 时间调整回来。

2

注册方法: 在 注册时选择 License server ,填 http://idea.lanyus.com ,然后点击 OK

package.json

The package.json file contains manifest data for your add-on, providing not only descriptive information about the add-on for presentation in the Add-ons Manager, but other metadata required of add-ons.

Some of its entries, such as icon, name, and description, have direct analogues in the install manifest format, and entries from package.json are written into the install manifest when the add-on is built using jpm xpi.

Others, such as lib, permissions, and preferences, represent instructions to the jpm tool itself to generate and include particular code and data structures in your add-on.

Creating a manifest

The package.json file is initially generated in your add-on's root directory the first time you run jpm init. It looks like this (assuming the add-on's directory is "my-addon"):

{
  "name": "my-addon",
  "title": "my-addon",
  "id": "jid1-1FERGV45e4f4f",
  "description": "a basic add-on",
  "author": "",
  "license": "MPL-2.0",
  "version": "0.1"
}

If you are using the new jpm tool, you can easily access manifest data from package.json by requiring it like any other module:

var title = require("./package.json").title;

Key reference

package.json may contain the following keys:

author

The name of the package's original author; this could be the name of a person or a company. Defaults to an empty string. It may include a optional URL in parentheses and an email address in angle brackets.

<p>This value will be used as the add-on's <a href="https://developer.mozilla.org/en-US/docs/Install_Manifests#creator"><code>em:creator</code></a> element in the <code>install.rdf</code> file generated by <code>cfx</code>.</p>

<div class="note"><strong>Note:</strong> <a href="https://developer.mozilla.org/Add-ons/SDK/Tools/jpm">jpm</a> supports <a href="https://docs.npmjs.com/files/package.json#people-fields-author-contributors" class="external external-icon">NodeJS people fields</a>.</div>
contributors

An array of additional author strings, identifying other contributors to the add-on.

<p>These values will be used as the add-on's <a href="https://developer.mozilla.org/en-US/docs/Install_Manifests#contributor"><code>em:contributor</code></a> elements in its <code>install.rdf</code>.</p>

<div class="note"><strong>Note:</strong> This is deprecated along with <code>cfx</code>; it's not available when using <a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/jpm">jpm</a>.</div>
dependencies

A string or an array of strings specifying the names of packages that this add-on requires in order to function properly.

description

The add-on's description; this is a human-readable message describing what the add-on does. This defaults to the text "a basic add-on".

<p>This value will be used as the add-on's <a href="https://developer.mozilla.org/en-US/docs/Install_Manifests#description"><code>em:description</code></a> element in its <code>install.rdf</code>.</p>
engines

Object with supported applications (key) and required version numbers (value).

<ul>
 <li><code>firefox</code>: Firefox Desktop</li>
 <li><code>fennec</code>: Firefox for Android</li>
</ul>

<p>Example:</p>

<pre><code>  "engines": {
"firefox": "&gt;=38.0a1",
"fennec": "&gt;=38.0a1"

}

fullName
Note: This is deprecated along with cfx; it's not available when using jpm.
<p>The full name of the package. It can contain spaces.</p>

<p>If this key is present its value will be used as the add-on's <a href="https://developer.mozilla.org/en-US/docs/Install_Manifests#name"><code>em:name</code></a> element in its <code>install.rdf</code>.</p>
harnessClassID
Note: This is deprecated along with cfx; it's not available when using jpm.
<p>String in the <a href="https://developer.mozilla.org/en-US/docs/Generating_GUIDs">GUID format</a>.</p>

<p>This is used as a <a href="https://developer.mozilla.org/en-US/docs/Creating_XPCOM_Components/An_Overview_of_XPCOM#CID"><code>classID</code></a> of the "harness service" XPCOM component. Defaults to a random GUID generated by <code>cfx</code>.</p>
homepage

The URL of the add-on's website.

<p>This value will be used as the add-on's <a href="https://developer.mozilla.org/en-US/docs/Install_Manifests#homepageURL"><code>em:homepageURL</code></a> element in its <code>install.rdf</code>.</p>
icon

The path to an image file containing the icon for the add-on. Defaults to icon.png. If no icon is specified, the standard add-on icon will be used by default.

<div class="warning">
<p>When using <a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/jpm">jpm</a>, relative path to the data directory (to make it re-usable for add-on HTML content) does not currently work. Instead you have to use following syntax:</p>

<p>resource://ID/data/icon-name.png</p>

<p>ID is the value from the <code>id </code>field. If it does <strong>not</strong> begin with the <code>@</code>-character, then <code>@</code> has to be escaped as <code>-at-</code> and <code>.</code> as <code>-dot-</code>.</p>
</div>

<p>This value will be used as the add-on's <a href="https://developer.mozilla.org/en-US/docs/Install_Manifests#iconURL"><code>em:iconURL</code></a> element in its <code>install.rdf</code>.</p>

<p>The icon may be up to 48x48 pixels in size (although a bigger icon is tolerated here too)</p>
icon64

Note: This is deprecated along with cfx; it's not available when using jpm.

<p><span style="background-color: rgba(212, 221, 228, 0.14902);">The path to an image</span> containing the large icon for the add-on. Defaults to <code>icon64.png</code>. If you don't provide an icon here, the same icon as specified by <code>icon</code> will be used.</p>

<p>This value will be used as the add-on's <a href="https://developer.mozilla.org/en-US/docs/Install_Manifests#icon64URL"><code>em:icon64URL</code></a> element in its <code>install.rdf</code>.</p>

<p>The icon may be up to 64x64 pixels in size.</p>
id

A globally unique identifier for the add-on.

<p>This value will be used as the add-on's <a href="https://developer.mozilla.org/en-US/docs/Install_Manifests#id"><code>em:id</code></a> element in its <code>install.rdf</code>.</p>

<p>See the <a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Guides/Program_ID">Program ID documentation</a>.</p>
lib

String representing the top-level module directory provided in this add-on. Defaults to "lib".

<div class="note">
<p><strong>Note:</strong> This is deprecated along with <code>cfx</code> and is not available when using <a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/jpm">jpm</a>.</p>
</div>
license

The name of the license under which the add-on is distributed, with an optional URL in parentheses. Defaults to "MPL-2.0".

<div class="note">
<p><strong>Note</strong>: It is recommend that you use an <a href="https://spdx.org/licenses/" class="external external-icon">SPDX license ID</a>.</p>
</div>
main

A string representing the name of a program module that is located in one of the top-level module directories specified by lib. Defaults to "main".

name

The add-on's name. This name cannot contain spaces or periods, and defaults to the name of the parent directory.

<p>When the add-on is built as an XPI, if the <a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/package_json#fullName"><code>fullName</code></a> and <a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/package_json#title"><code>title</code></a> keys are not present, <code>name</code> is used as the add-on's <a href="https://developer.mozilla.org/en-US/docs/Install_Manifests#name"><code>em:name</code></a> element in its <code>install.rdf</code>.</p>
packages

Note: This is deprecated along with cfx and is not available when using jpm.

<p>A string pointing to a directory containing additional packages. Defaults to <code>"packages"</code>.</p>
permissions

A set of permissions that the add-on needs.

<p><strong><code>private-browsing</code></strong>: a boolean indicating whether or not the add-on supports private browsing. If this value is not <code>true</code> or is omitted, then the add-on will not see any private windows or objects, such as tabs, that are associated with private windows. See the documentation for the <a href="https://developer.mozilla.org/en-US/Add-ons/SDK/High-Level_APIs/private-browsing"><code>private-browsing</code> module</a>.</p>

<p><strong><code>cross-domain-content</code></strong>: a list of domains for which content scripts are given cross-domain privileges to access content in iframes or to make XMLHTTPRequests. See the documentation for <a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Guides/Content_Scripts/Cross_Domain_Content_Scripts">enabling cross-domain content scripts</a>.</p>

<p><strong><code>multiprocess</code></strong>: a Boolean value declaring whether this add-on is, or is not, compatible with <a href="https://developer.mozilla.org/en-US/Add-ons/Working_with_multiprocess_Firefox">multiprocess Firefox</a>.</p>

<div class="note">
<p><strong>Note</strong> the <code>multiprocess</code> permission is not supported by <a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/cfx">cfx</a>.</p>
</div>
preferences

An array of JSON objects that use the following keys: name,type, value, title, and description. These JSON objects will be used to create a preferences interface for the add-on in the Add-ons Manager.

<p>See the documentation for the <a href="https://developer.mozilla.org/en-US/Add-ons/SDK/High-Level_APIs/simple-prefs"><code>simple-prefs</code> module</a>.</p>
preferences-branch Use this to specify an alternative branch for your add-on's simple-prefs. See "Simple-prefs in the preferences system" for more details.
title

The human-readable title of the package; this can contain spaces.

<p>If this key is present its value will be used as the add-on's <a href="https://developer.mozilla.org/en-US/docs/Install_Manifests#name"><code>em:name</code></a> element in its <code>install.rdf</code>.</p>
translators

An array of strings listing the people who contributed to the localization of this add-on.

<p>These values will be used as the add-on's <a href="https://developer.mozilla.org/en-US/docs/Install_Manifests#translator"><code>em:translator</code></a> elements in its <code>install.rdf</code>.</p>

<div class="note"><strong>Note:</strong> <a href="https://developer.mozilla.org/Add-ons/SDK/Tools/jpm">jpm</a> supports <a href="https://docs.npmjs.com/files/package.json#people-fields-author-contributors" class="external external-icon">NodeJS people fields</a>.</div>
updateKey

Same as the updateKey in an install.rdf file.

<p>See <a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/jpm#Supporting_updates_for_self-hosted_add-ons">Supporting updates for self-hosted add-ons</a>.</p>

<div class="note">
<p><strong>Note:</strong> This key is only available with <a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/jpm">jpm</a>.</p>
</div>

Same as the updateLink for an update.rdf file. Previously was --update-link in cfx.

<p>See <a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/jpm#Supporting_updates_for_self-hosted_add-ons">Supporting updates for self-hosted add-ons</a>.</p>

<div class="note">
<p><strong>Note:</strong> This key is only available with <a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/jpm">jpm</a>.</p>
</div>
updateURL

Same as the updateURL for an install.rdf file.

<p>See <a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/jpm#Supporting_updates_for_self-hosted_add-ons">Supporting updates for self-hosted add-ons</a>.</p>

<div class="note">
<p><strong>Note:</strong> This key is only available with <a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/jpm">jpm</a>.</p>
</div>
version

String representing the version of the add-on. Defaults to "0.0.1".

<p>This value is used as the add-on's <a href="https://developer.mozilla.org/en-US/docs/Install_Manifests#version"><code>em:version</code></a> element in its <code>install.rdf</code>.</p>

<div class="note">
<p><strong>Note:</strong> For <a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/jpm">jpm</a> the version must be a valid <a href="http://semver.org/" class="external external-icon">semver</a>.</p>
</div>

 

subprocess WindowsError 740

subprocess.call([r"magnify.exe",])

python运行一个外部程序,系统自带的放大镜程序。
运行失败提示740错误。
网上找了一下原来需要加上参数“shell=True”:

subprocess.call([r"magnify.exe",], shell=True)

python调试小技巧

很实用的小功能.
import traceback; traceback.print_stack()

可以打印出当前的堆栈.函数调用顺序..调试时候不用写个出错信息看堆栈了哈哈..

import bdb; bdb.Tdb().set_trace()

可以跟踪所在函数运行情况,调用执行所有行包括所在函数调用的子函数行都有,很详细...