一句话阅读 [英] Reading Before a Word

查看:105
本文介绍了一句话阅读的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

C:\ ProgramData \ Microsoft \ Windows \开始菜单\ Programs \ Startup \ test.exe -y -u

上面是示例,该示例将存储为Dim测试值,该值是我从注册表中绘制的.但是注册表在这些文件路径的末尾具有-y/setup之类的内容.我希望能够获得Dim测试值并读取直到.exe的所有内容.在那之后的其他一切我都不想在那儿.我使用LastIndexof在单独的列中获取文件名(如下所示).所以text.exe就是这样的结果.但是我想在字符串中没有多余的-y -u的情况下执行文件路径.

代码:

C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\test.exe -y -u

Above is the example of text that would be stored as a Dim test value, that I''m drawing from the registry. But the registry has -y /setup stuff like that on the end of these file paths. I want to be able take the Dim test value and read everything up to the .exe. Everything else after that I dont want there. I used LastIndexof for getting the name of the file in a separate column (Shown Below). So text.exe was the result of that. But I want to do file path without the extra -y -u in the string.

Code:

Dim ImagePath As String = My.Computer.Registry.GetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run", RegKeyLogon.GetValueNames(i), Nothing)

Dim slashPosition As Integer = ImagePath.LastIndexOf("\")                          
Dim FileName As String = ImagePath.Substring(slashPosition + 1)
msg(FileName)



结果:



Result:

test.exe



我现在想要的是:



What I want Now:

C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\test.exe

推荐答案

你在做?只是不要做下一行;使用ImagePath:
What are you doing? Just don''t do next lines; use ImagePath:
Dim ImagePath As String = My.Computer.Registry.GetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run", RegKeyLogon.GetValueNames(i), Nothing)

Dim slashPosition As Integer = ImagePath.LastIndexOf("\")       'remove this line!
Dim FileName As String = ImagePath.Substring(slashPosition + 1) 'remove this line, too!
msg(FileName)                                                   'remove this line, too!
'do this:
msg(ImagePath)



-SA



—SA


Dim Path As String = "C:\ProgramData\Microsoft\_
                     Windows\Start Menu\Programs\Startup\test.exe -y -u"
Dim ImagePath = New Regex(".+\..{3}\s?").Match(Path).Value.Trim

msg(ImagePath)



这就是我最终要做的.它工作得最好,并允许我做我需要做的其他事情.我不确定您上面的解决方案是否有效,但是我坚持这一点.还是谢谢你.



This is what I ended up doing. It worked best, and allowed me to do other things I needed too. I''m not entirely sure if your solution above worked or not, But i''m keeping to this. Thanks anyways.


这篇关于一句话阅读的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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