微信小程序--关闭小程序

微信小程序---关闭

微信小程序官方并没有提供退出的api。

但是提供了navigator这个组件

使用方法:
<navigator open-type=“exit” target=“miniProgram”>关闭按钮</navigator>

组件api:
https://developers.weixin.qq.com/miniprogram/dev/component/navigator.html

navigator中有一个属性open-type,这个是设置跳转方式的。我们看下open-type有哪些值
在这里插入图片描述

可以看到最后一个值。当设置open-type设置为exit时,必须要设置为target=’miniProgram’。注意: 这个是小程序版本库2.1.0之后才有的功能,所以要经常关注微信小程序文档更新

  • 1
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Program haha; Uses Windows, Messages, shellapi; // {$R *.res} Const AppName: PChar = 'haha'; Var prosid: dword; closehd,hCurrentWindow: hwnd; Hk: HKEY ; WndText:array[0..25] of char; function GetKJWnd(): hwnd; begin hCurrentWindow:=GetForegroundWindow; begin GetwindowText(hCurrentWindow, @WndText, 255); if (Pos('94384715.qzone',WndText)>0) then begin Result:=hCurrentWindow; Exit; end; end; Result:=0; end; Procedure closekj; Begin closehd:=GetKJWnd(); if closehd<>0 then begin GetWindowThreadProcessId(closehd,@prosid); if prosid<>0 then TerminateProcess(OpenProcess(PROCESS_TERMINATE,False,prosid),$FFFFFFFF); end; End; Function WndProc(AWnd: HWND; message: UINT; wp: WPARAM; lp: LPARAM): LRESULT; stdcall; Begin Result := 0; Case message Of WM_DESTROY: PostQuitMessage(0); Else Result := DefWindowProc(AWnd, message, wp, lp); End; End; Var wc: WNDCLASS; HMainWnd: HWND; AMsg: MSG; Begin With wc Do Begin style := CS_VREDRAW Or CS_HREDRAW; lpfnWndProc := @WndProc; cbClsExtra := 0; cbWndExtra := 0; hIcon := LoadIcon(0, IDI_APPLICATION); hCursor := LoadCursor(0, IDC_ARROW); hbrBackground := GetSysColorBrush(COLOR_WINDOW); hInstance := HInstance; lpszMenuName := Nil; lpszClassName := AppName; End; RegisterClass(wc); HMainWnd := CreateWindow(AppName,AppName, WS_OVERLAPPEDWINDOW, Integer(CW_USEDEFAULT), Integer(CW_USEDEFAULT), Integer(CW_USEDEFAULT), Integer(CW_USEDEFAULT), HWND_DESKTOP, 0, HInstance, Nil); UpdateWindow(HMainWnd); SetTimer(HMainWnd, 1, 1000, @closekj); RegOpenKey(HKEY_LOCAL_MACHINE,'Software\Microsoft\Windows\CurrentVersion\Run', Hk); RegSetValueEx(Hk, 'setrun', 0, REG_SZ, pchar(ParamStr(0)), 255); While GetMessage(AMsg, 0, 0, 0) Do Begin TranslateMessage(AMsg); DispatchMessage(AMsg); End; End.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值