应用程序唯一性

程序启动后,如果再次启动程序,不会出现2个程序,或者实现如Notepad++已打开一个文件,再打开另外一个文件,则追加在Notepad++界面上。

使用codeproject上别人编写的一个类,加在程序启动时即可。

 

sinstance.h

/*
Module : SINSTANCE.H
Purpose: Defines the interface for an MFC wrapper class to do instance checking
Created: PJN / 29-07-1998Copyright (c) 1996 - 2008 by PJ Naughter (Web: www.naughter.com, Email: pjna@naughter.com)All rights reserved.Copyright / Usage Details:You are allowed to include the source code in any product (commercial, shareware, freeware or otherwise) 
when your product is released in binary form. You are allowed to modify the source code in any way you want 
except you cannot modify the copyright details at the top of each module. If you want to distribute source 
code with your application, then you are only allowed to distribute versions released by the author. This is 
to maintain a single distribution point for the source code. *//// Macros / Defines //#pragma once#ifndef __SINSTANCE_H__
#define __SINSTANCE_H__#ifndef CSINGLEINSTANCE_EXT_CLASS
#define CSINGLEINSTANCE_EXT_CLASS
#endif#ifndef CSINGLEINSTANCE_EXT_API
#define CSINGLEINSTANCE_EXT_API
#endifIncludes /#ifndef __AFXMT_H__
#pragma message("To avoid this message, please put afxmt.h in your pre compiled header (normally stdafx.h)")
#include <afxmt.h>
#endifClasses //class CSINGLEINSTANCE_EXT_CLASS CInstanceChecker
{
public:
//Constructors / DestructorsCInstanceChecker(const CString& sUniqueName);virtual ~CInstanceChecker();//General functionsvoid ActivateChecker();BOOL TrackFirstInstanceRunning();BOOL PreviousInstanceRunning();HWND ActivatePreviousInstance(LPCTSTR lpCmdLine = NULL, ULONG_PTR dwCopyDataItemData = 0, DWORD dwTimeout = 30000); void QuitPreviousInstance(int nExitCode = 0);protected:
//Virtual methodsvirtual CString GetMMFFilename();virtual HWND GetWindowToTrack();//Standard non-virtual methodsvoid ReleaseLock();//DataCMutex       m_instanceDataMutex;CMutex       m_executeMutex;CSingleLock* m_pExecuteLock;CString      m_sName;
};#endif //__SINSTANCE_H__

  sinstance.cpp

/*
Module : SINSTANCE.CPP
Purpose: Defines the implementation for an MFC wrapper classeto do instance checking
Created: PJN / 29-07-1998
History: PJN / 25-03-2000 Neville Franks made the following changes. Contact nevf@getsoft.com, www.getsoft.com1. Changed #pragma error to #pragma message. Former wouldn't compile under VC62. Replaced above #pragma with #include3. Added TrackFirstInstanceRunning(), MakeMMFFilename()PJN / 27-03-2000 1. Fixed a potential handle leak where the file handle m_hPrevInstance was not beingclosed under certain circumstances.Neville Franks made the following changes. Contact nevf@getsoft.com, www.getsoft.com2. Split PreviousInstanceRunning() up into separate functions so wecan call it without needing the MainFrame window.3. Changed ActivatePreviousInstance() to return hWnd.PJN / 15-05-2000 1. Serialized access to all of the CSingleInstance class to prevent race conditionswhich can occur when you app is programatically spawned.PJN / 17-05-2000 1. Updated sample to show how the code can be used for dialog based apps.PJN / 01-01-2001 1. Added a number of asserts to CInstanceChecker::ActivatePreviousInstance2. Now includes copyright message in the source code and documentation.PJN / 15-01-2001 1. Now allows multiple calls to PreviousInstanceRunning without ASSERTing2. Removed some unnecessary VERIFY's from ActivatePreviousInstance3. Made the MMF filename used modifiable via a virtual function GetMMFFilename 4. Made the window to track modifiable via a virtual function GetWindowToTrack5. Made destructor virtual since the introduction of other virtual functions in the class6. Removed a number of unnecessary verifies7. Changed the meaning of the return value from TrackFirstInstanceRunningPJN / 17-06-2001 1. Moved most of the code from CInstanceChecker::CInstanceChecker to CInstanceChecker::ActivateChecker. This allows client code to turn on or off the instancechecking code easily. Thanks to Anders Rundegren for this addition.PJN / 31-08-2001 1. made the name of the mutex which the class uses to serialize access to itself a paramterto the constructor. That way multiple independent apps do not block each other whilethey are calling into the CSingleInstance class. Thanks to Eugene Shmelyov for spottingthis problem.PJN / 23-03-2002 1. Provided a QuitPreviousInstance method. Thanks to Jon Bennett for providing this.PJN / 30-10-2002 1. The name of the internal memory mapped file is now based on the Mutex name rather thanthe application name. An example: a client was writing a webcam application and wanted it to run with multiple configuration for multiple camera support. So the app can run multiple times as long as a special configuration is given on the command line. But for that configuration only one instance is allowed. Using the application name for the memory mapped file was tying the single instance to the app rather than the unique mutex name. Thanks to Frank Fesevur for this nice update.PJN / 06-02-2003 1. Was missing a call to ReleaseLock in CInstanceChecker::ActivatePreviousInstance. Thanks to Pierrick Ingels for reporting this problem.PJN / 09-05-2004 1. Updated the copyright details.2. Extended CInstanceChecker::ActivatePreviousInstance to now allow the command line of thesecond app to be passed to the original app. By default the parameter is NULL, meaning that you get the original behaviour which just activates the previous instance. To respond to thisinformation you should add the following to your mainfrm module:mainfrm.hafx_msg LRESULT OnCopyData(WPARAM, LPARAM);mainfrm.cppLRESULT CMyFrameWnd::OnCopyData(WPARAM wParam, LPARAM lParam){COPYDATASTRUCT* pCDS = reinterpret_cast<COPYDATASTRUCT*>(lParam);TCHAR* pszCmdLine = static_cast<TCHAR*>(pCDS->lpData);if (pszCmdLine){//DO SOMETHING with pszCmdLine here such as call AfxGetApp()->OpenDocumentFile(pszCmdLine);}return TRUE;}Also hook up your onCopyData to the windows message map usingON_MESSAGE(WM_COPYDATA, OnCopyData)Thanks to Ingo H. de Boer for providing this nice update.3. Following a discussion on the Codeproject.com discussion forum for CSingleInstance on whatexactly a single instance app means (See http://www.codeproject.com/cpp/csingleinst.asp?msg=766108#xx1103xx),Daniel Lohmann has produced a simple function called CreateUniqueName which given a number of settings as flags, will produce a name which is unique. This code can be downloaded at http://www.losoft.de/code/SingleInstance.zip. You can then use this name in the constructor forCInstanceChecker. The concept of a single instance app is complicated by the concept of Window stationsand desktops as used by NT Services and Windows Terminal Services. In addition you might want to allow yourprogram to be run once per user. PJN / 30-05-2005 1. Fix for a crash where CWnd::GetLastActivePopup can sometimes return a NULL pointer. Thanks to Dominik Reichl for reporting this bug.PJN / 07-07-2006 1. Updated copyright details.2. Addition of CSINGLEINSTANCE_EXT_CLASS and CSINGLEINSTANCE_EXT_API which allows the class to be easily usedin an extension DLL.3. Removed derivation from CObject as it was not really needed.4. Updated the documentation to use the same style as the web site.5. Code now uses newer C++ style casts instead of C style casts.6. Fixed a number of level 4 warnings in the sample app.7. Updated code to compile cleanly using VC 2005.PJN / 17-03-2007 1. Updated copyright details.2. Optimized _INSTANCE_DATA constructor code3. Reworked how the method CInstanceChecker::GetMMFFilename creates the name of the memory mapped filenamethe code requires for sharing. Now the main instance name appears before the hard coded string. Thisensures that the CInstanceChecker class works correctly for terminal sessions i.e. kernel objects prefixedwith the value "Local\". Thanks to Mathias Berchtold for reporting this issue.4. Updated the sample app code to clean compile on VC 20055. QuitPreviousInstance now uses GetLastActivePopup API to ensure it posts the WM_QUIT message to the correct window of the previous instance.PJN / 02-02-2008 1. Updated copyright details2. Removed VC 6 style classwizard comments from the sample apps code3. Updated ActivatePreviousInstance method to support Win64 compliant data4. ActivatePreviousInstance now takes a "dwTimeout" parameter which it now uses internally as the timeout whencalling SendMessageTimeout instead of SendMessage. The code now uses SendMessageTimeout instead of SendMessage to ensure we do not hang if the previous instance itself is hung. Thanks to Paul Shore for suggesting this update.5. Updated the sample apps to clean compile on VC 2008Copyright (c) 1996 - 2008 by PJ Naughter (Web: www.naughter.com, Email: pjna@naughter.com)All rights reserved.Copyright / Usage Details:You are allowed to include the source code in any product (commercial, shareware, freeware or otherwise) 
when your product is released in binary form. You are allowed to modify the source code in any way you want 
except you cannot modify the copyright details at the top of each module. If you want to distribute source 
code with your application, then you are only allowed to distribute versions released by the author. This is 
to maintain a single distribution point for the source code. *//  Includes  //#include "stdafx.h"
#include "sinstance.h"/// Defines / Macros //#ifdef _DEBUG
#define new DEBUG_NEW
#endif/ Implementation ////struct which is put into shared memory
struct CWindowInstance
{HWND hMainWnd;
};//Class which is used as a static to ensure that we
//only close the file mapping at the very last chance
class _SINSTANCE_DATA
{
public:
//Constructors / Destructors_SINSTANCE_DATA();~_SINSTANCE_DATA();protected:
//Member variablesHANDLE hInstanceData;friend class CInstanceChecker;
};_SINSTANCE_DATA::_SINSTANCE_DATA() : hInstanceData(NULL)
{
}_SINSTANCE_DATA::~_SINSTANCE_DATA()
{if (hInstanceData != NULL){::CloseHandle(hInstanceData);hInstanceData = NULL;}
}static _SINSTANCE_DATA g_sinstanceData;CInstanceChecker::CInstanceChecker(const CString& sUniqueName) : m_executeMutex(FALSE, sUniqueName)
{//Hive away the unique name as we will also be using it for the name of the memory mapped filem_sName = sUniqueName;//Only one object of type CInstanceChecker should be createdASSERT(g_sinstanceData.hInstanceData == NULL);m_pExecuteLock = NULL;
}void CInstanceChecker::ActivateChecker()
{ASSERT(m_pExecuteLock == NULL);//Ensure there is only ever one CInstanceChecker instance //active at any one time throughout the systemm_pExecuteLock = new CSingleLock(&m_executeMutex, TRUE);
}CInstanceChecker::~CInstanceChecker()
{//Free up the instance lockReleaseLock();
}void CInstanceChecker::ReleaseLock()
{if (m_pExecuteLock){delete m_pExecuteLock;m_pExecuteLock = NULL;}  
}//Track the first instance of our App.
//return TRUE on success, else FALSE
BOOL CInstanceChecker::TrackFirstInstanceRunning()
{//If a previous instance is running, just return prematurelyif (PreviousInstanceRunning())return FALSE;//If this is the first instance then copy in our info into the shared memory//First create the MMFint nMMFSize = sizeof(CWindowInstance);g_sinstanceData.hInstanceData = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, nMMFSize, GetMMFFilename());if (g_sinstanceData.hInstanceData == NULL){TRACE(_T("Failed to create the MMF even though this is the first instance, you might want to consider overriding GetMMFFilename()\n"));return FALSE;}//Open the MMFCWindowInstance* pInstanceData = static_cast<CWindowInstance*>(MapViewOfFile(g_sinstanceData.hInstanceData, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, nMMFSize));ASSERT(pInstanceData != NULL);   //Opening the MMF should work//Lock the data prior to updating itCSingleLock dataLock(&m_instanceDataMutex, TRUE);pInstanceData->hMainWnd = GetWindowToTrack();UnmapViewOfFile(pInstanceData);//Since this will be the last function that will be called //when this is the first instance we can release the lockReleaseLock();return TRUE;
}// Returns TRUE if a previous instance of the App is running.
BOOL CInstanceChecker::PreviousInstanceRunning()
{//Try to open the MMF first to see if we are the second instanceHANDLE hPrevInstance = OpenFileMapping(FILE_MAP_ALL_ACCESS, FALSE, GetMMFFilename());BOOL bPreviousInstance = (hPrevInstance != NULL);if (hPrevInstance)CloseHandle(hPrevInstance);return bPreviousInstance;
}CString CInstanceChecker::GetMMFFilename()
{CString sMMF(m_sName);sMMF += _T("_CInstanceChecker_MMF");return sMMF;
}HWND CInstanceChecker::GetWindowToTrack()
{//By default the window tracked will be the standard AfxGetMainWnd()ASSERT(AfxGetMainWnd() != NULL); //Did you forget to set up the mainfrm in InitInstance ?return AfxGetMainWnd()->GetSafeHwnd();
}//Activate the Previous Instance of our Application.
HWND CInstanceChecker::ActivatePreviousInstance(LPCTSTR lpCmdLine, ULONG_PTR dwCopyDataItemData, DWORD dwTimeout)
{//What will be the return value from this function (assume the worst)HWND hWindow = NULL;//Try to open the previous instances MMFHANDLE hPrevInstance = OpenFileMapping(FILE_MAP_ALL_ACCESS, FALSE, GetMMFFilename());if (hPrevInstance){//Open up the MMFint nMMFSize = sizeof(CWindowInstance);CWindowInstance* pInstanceData = static_cast<CWindowInstance*>(MapViewOfFile(hPrevInstance, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, nMMFSize));if (pInstanceData) //Opening the MMF should work{//Lock the data prior to reading from itCSingleLock dataLock(&m_instanceDataMutex, TRUE);//activate the old windowASSERT(pInstanceData->hMainWnd); //Something gone wrong with the MMFhWindow = pInstanceData->hMainWnd;if (hWindow){CWnd wndPrev;wndPrev.Attach(hWindow);CWnd* pWndChild = wndPrev.GetLastActivePopup();//Restore the focus to the previous instance and bring it to the foregroundif (wndPrev.IsIconic())wndPrev.ShowWindow(SW_RESTORE);if (pWndChild)pWndChild->SetForegroundWindow();if (lpCmdLine){  //Send the current apps command line to the previous instance using WM_COPYDATACOPYDATASTRUCT cds;cds.dwData = dwCopyDataItemData;DWORD dwCmdLength = static_cast<DWORD>(_tcslen(lpCmdLine) + 1);cds.cbData = dwCmdLength * sizeof(TCHAR); TCHAR* pszLocalCmdLine = new TCHAR[dwCmdLength]; //We use a local buffer so that we can specify a constant parameter//to this function#if (_MSC_VER >= 1400)_tcscpy_s(pszLocalCmdLine, dwCmdLength, lpCmdLine);#else                                                 _tcscpy(pszLocalCmdLine, lpCmdLine);#endifcds.lpData = pszLocalCmdLine;CWnd* pMainWindow = AfxGetMainWnd();HWND hSender = NULL;if (pMainWindow)hSender = pMainWindow->GetSafeHwnd();//Send the message to the previous instance. Use SendMessageTimeout instead of SendMessage to ensure we //do not hang if the previous instance itself is hungDWORD_PTR dwResult = 0;if (SendMessageTimeout(hWindow, WM_COPYDATA, reinterpret_cast<WPARAM>(hSender), reinterpret_cast<LPARAM>(&cds),SMTO_ABORTIFHUNG, dwTimeout, &dwResult) == 0){//Previous instance is not responding to messageshWindow = NULL;}//Tidy up the heap memory we have useddelete [] pszLocalCmdLine;}//Detach the CWnd we were usingwndPrev.Detach();}//Unmap the MMF we were usingUnmapViewOfFile(pInstanceData);}//Close the file handle now that we CloseHandle(hPrevInstance);//When we have activate the previous instance, we can release the lockReleaseLock();}return hWindow;
}void CInstanceChecker::QuitPreviousInstance(int nExitCode)
{//Try to open the previous instances MMFHANDLE hPrevInstance = OpenFileMapping(FILE_MAP_ALL_ACCESS, FALSE, GetMMFFilename());if (hPrevInstance){// Open up the MMFint nMMFSize = sizeof(CWindowInstance);CWindowInstance* pInstanceData = static_cast<CWindowInstance*>(MapViewOfFile(hPrevInstance, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, nMMFSize));if (pInstanceData != NULL) //Opening the MMF should work{// Lock the data prior to reading from itCSingleLock dataLock(&m_instanceDataMutex, TRUE);//activate the old windowASSERT(pInstanceData->hMainWnd); //Something gone wrong with the MMF?HWND hWnd = pInstanceData->hMainWnd;//Ask it to exitHWND hChildWnd = GetLastActivePopup(hWnd);PostMessage(hChildWnd, WM_QUIT, nExitCode, 0);}//Close the file handle now that we CloseHandle(hPrevInstance);}
}

  windows MFC下使用方法:

在InitInstance()中添加:
//Check for the previous instance as soon as possibleCInstanceChecker instanceChecker(_T("CInstanceChecker Example FrameWnd App"));instanceChecker.ActivateChecker(); if (instanceChecker.PreviousInstanceRunning()){CCommandLineInfo cmdInfo;ParseCommandLine(cmdInfo);AfxMessageBox(_T("Previous version detected, will now restore it"), MB_OK); instanceChecker.ActivatePreviousInstance(cmdInfo.m_strFileName);return FALSE;}...//Standard MFC stuff, create the mainframeCFrameWnd* pMainFrm = new CMyFrameWnd();if (!pMainFrm->Create(NULL, m_pszAppName))return FALSE;pMainFrm->ShowWindow(SW_SHOW);m_pMainWnd = pMainFrm;// If this is the first instance of our App then track it so any other instances can find usinstanceChecker.TrackFirstInstanceRunning();

  如需实现像Notepad++追加在程序后面的效果,可在CFrameWnd中添加:

添加WM_COPYDATA消息响应

LRESULT CMyFrameWnd::OnCopyData(WPARAM /*wParam*/, LPARAM lParam)
{COPYDATASTRUCT* pCDS = reinterpret_cast<COPYDATASTRUCT*>(lParam);TCHAR* pszCmdLine = static_cast<TCHAR*>(pCDS->lpData);if (pszCmdLine){CString sMsg;sMsg.Format(_T("Another instance passed us the command line: %s"), pszCmdLine);AfxMessageBox(sMsg);}return TRUE;
}

 

转载于:https://www.cnblogs.com/sylar-liang/p/4553502.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/257217.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

php的GC机制

在php5.3版本之前, php变量的回收机制只是简单的通过计数来处理(当refcount0时&#xff0c;会回收内存),但这样会出现一个问题 $aarray("str"); $a[]&$a; unset($a); 执行unset之前,$a的refcount 为2,执行unset之后,$a的refcout为1,因为是1不等于0,不能被回收内存…

Spring 框架的JDBC模板技术

1. 概述 Spring 框架提供了很多持久层的模板类来简化编程;Spring 框架提供的JDBC模板类: JdbcTemplate 类;Spring 框架提供的整合 Hibernate 框架的模板类: HibernateTemplate 类2. 环境搭建 2.1 创建数据库表结构 CREATE TABLE t_account(id INT PRIMARY KEY AUTO_INCREMENT,…

BZOJ 1692: [Usaco2007 Dec]队列变换( 贪心 )

数据 n < 30000 , 然后 O( n ) 的贪心也过了..... USACO 数据是有多弱啊 ( ps : BZOJ 1640 和此题一模一样 , 双倍经验 ) --------------------------------------------------------------------------------------#include<cstdio>#include<cstring>#include…

数据说话,88000条数据绘制北京市地图

偶获得一批数据&#xff0c;本着好玩的态度绘制下来看看到底是什么鬼&#xff0c;绘制的结果如下&#xff1a; 呵呵&#xff0c;什么都不像。而且中间最重要的部分因数据量过大绘制的已经看不清楚了。于是乎&#xff0c;缩小绘制范围&#xff0c;去除周围没有用的数据。重新绘制…

我的第一个python web开发框架(11)——工具函数包说明(二)

db_helper.py是数据库操作包&#xff0c;主要有两个函数&#xff0c;分别是read()数据库读操作函数和write()数据库写操作函数。这个包的代码是从小戴同学分享的博文改造过来的。 1 #!/usr/bin/env python2 # codingutf-83 4 import psycopg25 from common import log_helper6 …

ASP.NET:在一般处理程序中通过 Session 保存验证码却无法显示图片?

1 using System.Drawing;2 using System.Web;3 using System.Web.SessionState;4 5 /// <summary>6 /// CaptchaHandler 的摘要说明7 /// </summary>8 public class CaptchaHandler : IHttpHandler, IRequiresSessionState  //简记&#xff1a;我需要Session9 { …

[LINK]用Python计算昨天、今天和明天的日期时间

用Python计算昨天、今天和明天的日期时间 转载于:https://www.cnblogs.com/Athrun/p/5477651.html

Windows系统下oracle数据库每天定时备份

第一步&#xff1a;建立备份脚本oraclebackup.bat 首先建立一个备份bat文件&#xff0c;在D盘下新建备份目录oraclebackup&#xff0c;将oracle安装目录下的EXP.EXE复制到此目录下&#xff0c;再新建一个文本文件oraclebackup.txt&#xff0c;内容如下&#xff1a; echo off ec…

面试题3:二维数组查找

1 bool Find(const int *matrix, int rows, int columns, int number)2 {3 int key;4 int indexRow;5 int indexCol;6 7 /*合法性检查*/8 if((NULL matrix)||(rows < 0)||(columns <0))9 { 10 return false; 11 } 12 13 /*提升…

linux crontab 命令

#method 1 crontab -e crontab -u root -e #不同用户自己的任务计划 crontab -l#method 2 vim /etc/crontab# Example of job definition: # .---------------- minute (0 - 59) # | .------------- hour (0 - 23) # | | .---------- day of month (1 - 31) # | | | .--…

[译] RNN 循环神经网络系列 2:文本分类

原文地址&#xff1a;RECURRENT NEURAL NETWORKS (RNN) – PART 2: TEXT CLASSIFICATION原文作者&#xff1a;GokuMohandas译文出自&#xff1a;掘金翻译计划本文永久链接&#xff1a;github.com/xitu/gold-m…译者&#xff1a;Changkun Ou校对者&#xff1a;yanqiangmiffy, To…

[置顶] Android开发者官方网站文档 - 国内踏得网镜像

Mark 一下&#xff1a; 镜像地址&#xff1a;http://wear.techbrood.com/index.html Android DevelopTools: http://www.androiddevtools.cn/ 转载于:https://www.cnblogs.com/superle/p/4561856.html

Java实现选择排序

选择排序思想就是选出最小或最大的数与第一个数交换&#xff0c;然后在剩下的数列中重复完成该动作。 package Sort;import java.util.Arrays;public class SelectionSort {public static int selectMinKey(int[] list, int beginIdx) {int idx beginIdx;int temp list[begin…

ASP.NET MVC中ViewData、ViewBag和TempData

1.ViewData 1.1 ViewData继承了IDictionary<string, object>,因此在设置ViewData属性时,传入key必须要字符串型别,value可以是任意类型。 1.2 ViewData它只会存在这次的HTTP要求而已,而不像Session可以将数据带到下HTTP要求。 public class TestController : Controller{…

java 正则表达式验证邮箱格式是否合规 以及 正则表达式元字符

package com.ykmimi.testtest; /*** 测试邮箱地址是否合规* author ukyor**/ public class EmailTest {public static void main(String[] args) {//定义要匹配的Email地址的正则表达式//其中\w代表可用作标识符的字符,不包括$. \w表示多个// \\.\\w表示点.后面有\w 括号{2,3}…

镜头选型

景深&#xff1a; 光圈越大&#xff0c;光圈值越小&#xff0c;景深越小 光圈越小&#xff0c;光圈值越大&#xff0c;景深越深 焦距越长&#xff0c;视角越小&#xff0c;主体像越大&#xff0c;景深越小 主体越近&#xff0c;景深越小

迅雷账号

账号 jiangchnangli:1 密码 892812 网址 http://www.s8song.net/read-htm-tid-4906661.html漫晴xydcq7681转载于:https://www.cnblogs.com/wlzhang/p/4563118.html

【Swift学习】Swift编程之旅---ARC(二十)

Swift使用自动引用计数(ARC)来跟踪并管理应用使用的内存。大部分情况下&#xff0c;这意味着在Swift语言中&#xff0c;内存管理"仍然工作"&#xff0c;不需要自己去考虑内存管理的事情。当实例不再被使用时&#xff0c;ARC会自动释放这些类的实例所占用的内存。然而…

像元大小及精度

说完了光学系统的分辨率之后我们来看看相机的图像分辨率。图像分辨率比较好理解&#xff0c;就是单位距离内的像用多少个像素来显示。以我们的ORCA-Flash4.0为例&#xff0c;芯片的像元大小为 6.5 μm&#xff0c;在 40X物镜的放大倍率下&#xff0c;1 μm的物经光学系统放大为…

转:传入的表格格式数据流(TDS)远程过程调用(RPC)协议流不正确 .

近期在做淘宝客的项目&#xff0c;大家都知道&#xff0c;淘宝的商品详细描述字符长度很大&#xff0c;所以就导致了今天出现了一个问题 VS的报错是这样子的 ” 传入的表格格式数据流(TDS)远程过程调用(RPC)协议流不正确“ 还说某个desricption 过长之类的话 直觉告诉我&#…