[pls Help] Converting string to uint16 for FindWindow in WinApi

agolangf · · 659 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Hi, I am trying to make one of my windows always ontop that I have built using go-sciter.</p> <p>I&#39;m using this library <a href="https://github.com/AllenDang/w32/blob/master/user32.go#L213" rel="nofollow">https://github.com/AllenDang/w32/blob/master/user32.go#L213</a></p> <p>and the function is</p> <pre><code>func FindWindowW(className, windowName *uint16) HWND { ret, _, _ := procFindWindowW.Call( uintptr(unsafe.Pointer(className)), uintptr(unsafe.Pointer(windowName))) return HWND(ret) } </code></pre> <p>I&#39;m allowed to use nil as an argument for classname, am I supposed to cast a string to uint16 for the second argument? Or are there any better ways to make a window always-on-top?</p> <hr/>**评论:**<br/><br/>SSoreil: <pre><p>syscall.StringToUTF16Ptr will do the job here. It seems this function is deprecated, the syscall package has a function with a very similar name that will return both the wide string and an error.</p> <p>The syscall package is pretty dead for these types of functions, I recommend pulling from golang.org/x/sys/windows</p> <p>That has UTF16PtrFromString.</p> <p>As far as Windows specific stuff alike always on top I am not sure, only thing I ever did was open a window and draw in to it haha.</p></pre>69beards: <pre><p>MUCHOS GRACIAS</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

659 次点击  
加入收藏 微博
0 回复
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传