转载地址:http://blog.csdn.net/gdutxiaoxu/article/details/53008266
Thursday, 5 October 2017
Detect an internet connection activation with Delphi
uses WinInet;
function IsConnected: boolean;
const
// local system uses a modem to connect to the Internet.
INTERNET_CONNECTION_MODEM = 1;
// local system uses a local area network to connect to the Internet.
INTERNET_CONNECTION_LAN = 2;
// local system uses a proxy server to connect to the Internet.
INTERNET_CONNECTION_PROXY = 4;
// local system's modem is busy with a non-Internet connection.
INTERNET_CONNECTION_MODEM_BUSY = 8;
var
dwConnectionTypes : DWORD;
begin
dwConnectionTypes := INTERNET_CONNECTION_MODEM +
INTERNET_CONNECTION_LAN +
INTERNET_CONNECTION_PROXY;
Result := InternetGetConnectedState(@dwConnectionTypes,0);
end;
Delphi 防止程序多次运行《转》
//防止多次打开
unit MultInst;
interface
uses Windows ,Messages, SysUtils, Classes, Forms;
implementation
const
STR_UNIQUE = '{2BE6D96E-827F-4BF9-B33E-8740412CDE96}';
MI_ACTIVEAPP = 1; {激活应用程序}
MI_GETHANDLE = 2; {取得句柄}
var
iMessageID : Integer;
OldWProc : TFNWndProc;
MutHandle : THandle;
BSMRecipients : DWORD;
function NewWndProc(Handle: HWND; Msg: Integer; wParam, lParam: Longint): Longint; stdcall;
begin
Result := 0;
if Msg = iMessageID then
begin
case wParam of
MI_ACTIVEAPP: {激活应用程序}
if lParam<>0 then
begin
{收到消息的激活前一个实例}
{为什么要在另一个程序中激活?}
{因为在同一个进程中SetForegroundWindow并不能把窗体提到最前}
if IsIconic(lParam) then
OpenIcon(lParam)
else
SetForegroundWindow(lParam);
Application.Terminate; {终止本实例}
end;
MI_GETHANDLE: {取得程序句柄}
begin
PostMessage(HWND(lParam), iMessageID, MI_ACTIVEAPP, Application.Handle);
end;
end;
end
else
Result := CallWindowProc(OldWProc, Handle, Msg, wParam, lParam);
end;
procedure InitInstance;
begin
{取代应用程序的消息处理}
OldWProc := TFNWndProc(SetWindowLong(Application.Handle, GWL_WNDPROC, Longint(@NewWndProc)));
{打开互斥对象}
MutHandle := OpenMutex(MUTEX_ALL_ACCESS, False, STR_UNIQUE);
if MutHandle = 0 then
begin
{建立互斥对象}
MutHandle := CreateMutex(nil, False, STR_UNIQUE);
end
else
begin
Application.ShowMainForm := False;
{已经有程序实例,广播消息取得实例句柄}
BSMRecipients := BSM_APPLICATIONS;
BroadcastSystemMessage(BSF_POSTMESSAGE or BSF_POSTMESSAGE,@BSMRecipients,iMessageID,MI_GETHANDLE,Application.Handle);
//BroadCastSystemMessage(BSF_IGNORECURRENTTASK or BSF_POSTMESSAGE, @BSMRecipients, iMessageID, MI_GETHANDLE,Application.Handle);
end;
end;
initialization
{注册消息}
iMessageID := RegisterWindowMessage(STR_UNIQUE);
InitInstance;
finalization
{还原消息处理过程}
if OldWProc <> Nil then
SetWindowLong(Application.Handle, GWL_WNDPROC, LongInt(OldWProc));
{关闭互斥对象}
if MutHandle <> 0 then
CloseHandle(MutHandle);
end.
unit MultInst;
interface
uses Windows ,Messages, SysUtils, Classes, Forms;
implementation
const
STR_UNIQUE = '{2BE6D96E-827F-4BF9-B33E-8740412CDE96}';
MI_ACTIVEAPP = 1; {激活应用程序}
MI_GETHANDLE = 2; {取得句柄}
var
iMessageID : Integer;
OldWProc : TFNWndProc;
MutHandle : THandle;
BSMRecipients : DWORD;
function NewWndProc(Handle: HWND; Msg: Integer; wParam, lParam: Longint): Longint; stdcall;
begin
Result := 0;
if Msg = iMessageID then
begin
case wParam of
MI_ACTIVEAPP: {激活应用程序}
if lParam<>0 then
begin
{收到消息的激活前一个实例}
{为什么要在另一个程序中激活?}
{因为在同一个进程中SetForegroundWindow并不能把窗体提到最前}
if IsIconic(lParam) then
OpenIcon(lParam)
else
SetForegroundWindow(lParam);
Application.Terminate; {终止本实例}
end;
MI_GETHANDLE: {取得程序句柄}
begin
PostMessage(HWND(lParam), iMessageID, MI_ACTIVEAPP, Application.Handle);
end;
end;
end
else
Result := CallWindowProc(OldWProc, Handle, Msg, wParam, lParam);
end;
procedure InitInstance;
begin
{取代应用程序的消息处理}
OldWProc := TFNWndProc(SetWindowLong(Application.Handle, GWL_WNDPROC, Longint(@NewWndProc)));
{打开互斥对象}
MutHandle := OpenMutex(MUTEX_ALL_ACCESS, False, STR_UNIQUE);
if MutHandle = 0 then
begin
{建立互斥对象}
MutHandle := CreateMutex(nil, False, STR_UNIQUE);
end
else
begin
Application.ShowMainForm := False;
{已经有程序实例,广播消息取得实例句柄}
BSMRecipients := BSM_APPLICATIONS;
BroadcastSystemMessage(BSF_POSTMESSAGE or BSF_POSTMESSAGE,@BSMRecipients,iMessageID,MI_GETHANDLE,Application.Handle);
//BroadCastSystemMessage(BSF_IGNORECURRENTTASK or BSF_POSTMESSAGE, @BSMRecipients, iMessageID, MI_GETHANDLE,Application.Handle);
end;
end;
initialization
{注册消息}
iMessageID := RegisterWindowMessage(STR_UNIQUE);
InitInstance;
finalization
{还原消息处理过程}
if OldWProc <> Nil then
SetWindowLong(Application.Handle, GWL_WNDPROC, LongInt(OldWProc));
{关闭互斥对象}
if MutHandle <> 0 then
CloseHandle(MutHandle);
end.
Delphi获取CPU CPUID《转》
uses
ActiveX, ComObj;
function GetWMIProperty(WMIType, WMIProperty:AnsiString):String;
var
Wmi, Objs, Obj:OleVariant;
Enum:IEnumVariant;
C:Cardinal;
begin
try
Wmi:= CreateOleObject(AnsiString('WbemScripting.SWbemLocator'));
Objs := Wmi.ConnectServer(AnsiString('.'),AnsiString('root\cimv2')).ExecQuery(AnsiString('Select * from Win32_'+WMIType));
Enum:=IEnumVariant(IUnknown(Objs._NewEnum));
Enum.Reset;
Enum.Next(1,Obj,C);
Obj:=Obj.Properties_.Item(WMIProperty,0).Value;
if VarIsArray(Obj) then Result:=Obj[0]
else Result:=Obj;
except
Result:='Error';
end;
end;
ShowMessage(GetWMIProperty('Processor','ProcessorId'));
【转】http://www.cnblogs.com/LceMeaning/p/7284202.html
ActiveX, ComObj;
function GetWMIProperty(WMIType, WMIProperty:AnsiString):String;
var
Wmi, Objs, Obj:OleVariant;
Enum:IEnumVariant;
C:Cardinal;
begin
try
Wmi:= CreateOleObject(AnsiString('WbemScripting.SWbemLocator'));
Objs := Wmi.ConnectServer(AnsiString('.'),AnsiString('root\cimv2')).ExecQuery(AnsiString('Select * from Win32_'+WMIType));
Enum:=IEnumVariant(IUnknown(Objs._NewEnum));
Enum.Reset;
Enum.Next(1,Obj,C);
Obj:=Obj.Properties_.Item(WMIProperty,0).Value;
if VarIsArray(Obj) then Result:=Obj[0]
else Result:=Obj;
except
Result:='Error';
end;
end;
ShowMessage(GetWMIProperty('Processor','ProcessorId'));
【转】http://www.cnblogs.com/LceMeaning/p/7284202.html
Wednesday, 4 October 2017
Tuesday, 3 October 2017
Monday, 2 October 2017
SDK Error
1
C:\Users\Public\Documents\Embarcadero\Studio\17.0\PlatformSDKs\android-sdk-windows\build-tools\22.0.1\ZipAlign.exe
C:\Users\x\AppData\Local\Android\android-sdk\build-tools\26.0.0\ZipAlign.exe
2
C:\Users\Public\Documents\Embarcadero\Studio\17.0\PlatformSDKs\android-sdk-windows\build-tools\22.0.1\Aapt.exe
C:\Users\x\AppData\Local\Android\android-sdk\build-tools\26.0.0
C:\Users\Public\Documents\Embarcadero\Studio\17.0\PlatformSDKs\android-sdk-windows\platforms\android-22
C:\Users\Public\Documents\Embarcadero\Studio\17.0\PlatformSDKs\android-sdk-windows\platforms\android-26
2018 Mar 30 added
Subscribe to:
Posts (Atom)
zomok E-commerce system plan. Choose your online ordering system. No-risk 30 day free trial. Then USD 9/month. No credit card required.
zomok E-commerce system plan. Choose your online ordering system. No-risk 30 day free trial. Then USD 9/month. No credit card required. h...
-
DePauhGarden BabaCuisineBatuKawan ShunkaBatuKawan YenBatuKawan PanPanBatuKawan CheongfatttzeCafeMangga Iramadining AkkasCurryHouse Restauran...


