[VB.NET]请问在WINCE中怎么获得当前线程ID呢?有些难度的问题呀!!!!!!

VB.NET源码-156个实用实例哦…… <script type="text/javascript"> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
请问在WINCE中怎么获得当前线程ID呢?有些难度的问题呀!!!!!!
请问在WINCE中怎么获得当前线程ID呢?
在WINDOWS XP中的kernel32.dll有GetCurrentThreadId方法获得当前线程ID,不知道在WINOWS CE中是用什么函数获得线程ID呢?
好象在WINDOWS CE中对应kernel32.dll的是coredll.dll,只是不知道在这个DLL中是否有获得当前线程ID的方法呢?
__________________________________________________________________________
GetCurrentThread

Requirements
OS Versions: Windows CE 1.0 and later.
Header: Kfuncs.h.
Link Library: Coredll.lib.
This function returns a pseudohandle for the current thread.

HANDLE GetCurrentThread(void);
Parameters
None.

Return Values
The return value is a pseudohandle for the current thread.

Remarks
A pseudohandle is a special constant that is interpreted as the current thread handle. The calling thread can use this handle to specify itself whenever a thread handle is required.

This handle has the maximum possible access to the thread object.

The function cannot be used by one thread to create a handle that can be used by other threads to refer to the first thread. The handle is always interpreted as referring to the thread that is using it.

The pseudohandle need not be closed when it is no longer needed. Calling the CloseHandle function with this handle has no effect.

Requirements
OS Versions: Windows CE 1.0 and later.
Header: Kfuncs.h.
Link Library: Coredll.lib.


GetCurrentThreadId

Requirements
OS Versions: Windows CE 1.0 and later.
Header: Kfuncs.h.
Link Library: Coredll.lib.
This function returns the thread identifier, which is used as a handle of the calling thread.

DWORD GetCurrentThreadId(void);
Parameters
None.

Return Values
The thread identifier of the calling thread indicates success.

Remarks
Until the thread terminates, the thread identifier uniquely identifies the thread throughout the system. This identifier is also the handle of the thread.

Requirements
OS Versions: Windows CE 1.0 and later.
Header: Kfuncs.h.
Link Library: Coredll.lib.

See Also
GetCurrentThread
__________________________________________________________________________
可以下载个evc的帮助文档。
__________________________________________________________________________
不行,报错说在coredll.dll中没有找到GetCurrentThreadId.
我的实现代码如下:

Private Const WH_MOUSE As Integer = 20
Private hHook As Integer = 0
Private HookProc As CallBack

_
Public Overloads Shared Function GetCurrentThreadId() As Integer
End Function
_
Public Overloads Shared Function CallNextHookEx(ByVal idHook As Integer, ByVal nCode As Integer, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As Integer
End Function

Public Delegate Function CallBack(ByVal nCode As Integer, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As Integer

Private Function SetHook() As Integer
HookProc = New CallBack(AddressOf MouseProc)
hHook = SetWindowsHookExW(WH_MOUSE, HookProc, IntPtr.Zero, GetCurrentThreadId)
Return hHook
End Function

Private Function MouseProc(ByVal nCode As Integer, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As Integer
Do something.
Return CallNextHookEx(hHook, nCode, wParam, lParam)
End Function

帮忙看看,到底是那里不对呢?
这些代码在普通的VS.NET 2005的APPLICATION工程下是能正常运行的,但是换成了WINCE工程后就有问题了.
__________________________________________________________________________
下载一个.net CF看看。
里面也没直接的获取当前线程的id,不过用的是这个:
[DllImport( CoreDll.DLL , EntryPoint= CreateProcess , SetLastError=true)]
internal extern static int CreateProcessCE(string pszImageName, string pszCmdLine, IntPtr psaProcess, IntPtr psaThread, int fInheritHandles, int fdwCreate, IntPtr pvEnvironment, IntPtr pszCurDir, IntPtr psiStartInfo, PROCESS_INFORMATION pi);


internal sealed class PROCESS_INFORMATION
{
public IntPtr hProcess = IntPtr.Zero;
public IntPtr hThread = IntPtr.Zero;
public int dwProcessID = 0;
public int dwThreadID = 0;
}

这里有线程id
__________________________________________________________________________
是不是换个思路。先启动一个外壳程序,然后外壳用这个api启动你的主程序,启动之后把threadID通过进程同步方式或者剪贴板或者消息传递给你的主程序。
__________________________________________________________________________
给你个参考网站:

http://www.pinvoke.net/default.aspx/coredll.CreateProcess

左侧coredll.dll的api列表里面确实没有GetCurrentThreadId

只能帮你这些了,没开发过wince程序
__________________________________________________________________________
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值