如何使用VBScript读取内存值?

发布于 2024-10-08 10:12:51 字数 351 浏览 0 评论 0原文

我想使用 VBScript 直接从另一个正在运行的应用程序的内存中读取值。
我似乎找不到有关在 VBScript 中使用 ReadProcessMemory() 的信息。

我打算在 Quick Test Pro 中使用它来对需要测试的应用程序进行屏幕抓取。 该应用程序不使用任何标准控件,并且使用 QTP 的 OCR 功能无法为我们提供可靠的结果。

目前,我们使用 AutoIT 编写的代码可以直接从内存中读取该应用程序的值并将其转换为 ASCII。但我们希望消除对此的依赖,并且在 QTP 中使用 VBScript 将是理想的选择。

那么谁能告诉我如何使用 VBScript 从内存中的可执行文件读取值?

I want to use VBScript to read values directly out of memory of another running application.
I can't seem to find information on using ReadProcessMemory() in VBScript.

I intend to use this in Quick Test Pro to do screen scraping of an application that needs testing.
This application does not use any standard controls and using QTP's OCR abilities does not provide us with reliable results.

We currently have code written in AutoIT that reads values of this application directly from memory and converts it to ASCII. But we want to remove the reliance on that and using VBScript from within QTP would be ideal.

So can anyone tell me how I can read values from an executable in memory using VBScript?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

辞取 2024-10-15 10:12:51

您不能直接在 VBScript 中执行此操作。 正如 Josh Einstein 上面的评论所提到的,直接从 VBScript 调用本机 Windows API 函数是不可能的。造成这种情况的主要原因有两个。首先,用这种脚本语言编写的代码如果能够直接调用本机代码,就会带来明显的安全风险。其次,VBScript 只有一种数据类型 (Variant),它无法与大多数 Windows API 函数的返回值一起正常工作。

相反,您必须将所需的本机 API 函数包装在 ActiveX DLL(COM 自动化对象)中,然后从 VBScript 调用该库中的函数。包装器 DLL 将专门为 VBScript 互操作性而设计,并将处理任何必要的数据类型转换,仅公开 Variant 类型并包含所有必要的(或可能必要的!)错误处理例程。使用 VB 6 是实现此目的最快、最简单的方法,甚至不需要您学习新语言,但如果您习惯的话,也可以使用 C++ 实现此目的。

You can't do this in VBScript directly. As Josh Einstein's comment above mentions, it's impossible to call native Windows API functions directly from VBScript. There are two major reasons why this is the case. First, it would pose obvious security risks for code written in such a scripting language to be able to call native code directly. And second, VBScript only has one data type (Variant), which is not going to work properly with the return values of most of the Windows API functions.

Instead, you'll have to wrap the native API functions that you need in an ActiveX DLL (COM automation object), and then call functions from that library from your VBScript. The wrapper DLL would be designed specifically for VBScript-interoperability and would take care of any necessary data-type conversions, exposing only Variant types and containing all of the necessary (or potentially necessary!) error handling routines. Using VB 6 is the quickest and easiest way to do this and doesn't even require you to learn a new language, but you can also do this from C++, if you're comfortable there.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文