问题 - TCHAR作为LPARAM属于另一个进程/线程的窗口 [英] Problem - TCHAR as LPARAM to a window that belongs to another process/thread

查看:153
本文介绍了问题 - TCHAR作为LPARAM属于另一个进程/线程的窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我玩/实现窗口通过c书的例子,有一些关于dll注入部分,偷窥我,我不能解决它。

So i am playing/implementingtomyown with windows via c book examples and there is something about dll injection part that boggles me and i can't solve it.

我创建了一个属于另一个线程/进程的对话框,我试图发送它TCHAR变量,因此它可以在一些函数中使用该var tchar在同一个dll文件)

I created a dialog that belongs to another thread/process and i am trying to send it TCHAR variable so it can then use that var in some function(both the function and tchar are in the same dll file)

所以当对话框被创建,并在另一个线程中,我发送一个消息。

So when the dialog is created and sitting well in another thread i send it a message.

首先我声明tchar

First i declare tchar

TCHAR finalpath[MAX_PATH];

然后,我只是填充它的信息(我做这个在dll线程,线程,让我也提到我必须这样做在dll线程,因为这只有方式填充所需的tchar(我需要得到dll工作目录和填充它在tchar))

Then later i just fill it with info( i do this in the dll thread, not in the dialog's thread, let me also mention that i must do this in the dll thread because thats only way to fill the required tchar(i am required to get dll working directory and fill it in tchar))

所以,当我得到这个信息在我的tchar我试图发送消息到对话框,并使用tchar作为LPARAM(wparam是hwnd btw)

So, when i get this info in my tchar i am trying to send a message to the dialog and use tchar as LPARAM(wparam is hwnd btw)

SendMessage(hWndDIPS, WM_APP, (WPARAM) lista, (LPARAM)finalpath); 

之后,我在另一个线程对话过程循环中做基本的作业...

Afterwards i do basic schoolwork in another threads dialog procedure loop...

INT_PTR WINAPI Dlg_Proc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {

   switch (uMsg) {
      chHANDLE_DLGMSG(hWnd, WM_CLOSE, Dlg_OnClose);

      case WM_APP:


  SaveListViewItemPositions((HWND) wParam, (TCHAR)lParam);
         break;
   }

   return(FALSE);
}

应该接收参数的函数如下所示。

Function that is supposed to receive the parameter(this function resides in shared dll and is called by the procedure as you see above is defined as follows..

void SaveListViewItemPositions(HWND hWndLV,TCHAR sejv []){
...}

void SaveListViewItemPositions(HWND hWndLV, TCHAR sejv[]) { ...}

我从中得到的编译器错误是

The compiler error i get from this is

Error 7 error C2664: 'SaveListViewItemPositions' : cannot convert parameter 2 from 'TCHAR' to 'TCHAR []'

我不知道为什么会发生这种情况如果tchar是数组,然后我需要使用它的参数中添加的参数如何使用数组(更不要说,如果我不这样做,它给我更多的错误和不能在函数中使用参数)

So i have no idea why is this happening. If tchar is array then i need to use it in parameters with [] added as thats how arrays are used in parameters(not to mention that if i dont do it it gives me more errors and i cant use the parameter in function anyways)

那么为什么不转换呢?

感谢

推荐答案

我认为你的问题是你将LPARAM转换为TCHAR而不是TCHAR数组(TCHAR *)。尝试更改它,看看是否修复了问题。

I think that your problem is that you're typecasting the LPARAM to a TCHAR instead of an array of TCHARs (TCHAR*). Try changing that and see if it fixes things.

这篇关于问题 - TCHAR作为LPARAM属于另一个进程/线程的窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆