SysCmd作为后期绑定? [英] SysCmd as late binding?

查看:133
本文介绍了SysCmd作为后期绑定?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我这样做:


strAccessPath = SysCmd(acSysCmdAccessDir)& msaccess.exe


在vb可执行文件中执行它的样子。


如果删除对访问对象的引用库这个似乎只是应用程序窒息的

行。由于Access Obj库是最可能位于非标准位置的b $ b,我想知道如何在没有它的情况下这样做。

我可以在上面做后期绑定?


实际上,是否可以使所有引用后期绑定? DAO,VB,VBA MS

脚本等


你的,Mike MacSween

解决方案

Mike,

SysCmd可以从Application对象读取,所以(用VB .exe格式)......


''** *******************************************

Private Const acSysCmdAccessDir = 9


Private Sub Command1_Click()

Dim appAccess As Object

Dim strAccessPath As String


设置appAccess = CreateObject(" Access.Application")

strAccessPath = appAccess.SysCmd(acSysCmdAccessDir)& msaccess.exe


设置appAccess = Nothing

结束子


''**** *************************************


。 ...没有对Access的引用。

不,不可能晚到所有对象绑定但绝大多数可以



-

Terry Kreft

MVP Microsoft Access

" Mike MacSween" < MI ****************** @ btinternet.com>在消息中写道

news:41 *********************** @ news.aaisp.net.uk ..。

我这样做:

strAccessPath = SysCmd(acSysCmdAccessDir)& msaccess.exe

在vb可执行文件中执行它的样子。

如果我删除对访问对象库的引用,这似乎是
应用程序窒息的唯一一行。由于Access Obj库是最可能位于非标准位置的库,我想知道如何在没有
的情况下这样做。我可以在上面进行后期绑定吗?

实际上,是否可以使所有引用后期绑定? DAO,VB,VBA MS
Scripting等

你的,Mike MacSween



7月26 2004年,04:01 am,Mike MacSween

< mi ****************** @ btinternet.com>写在

news:41 *********************** @ news.aaisp.net.uk:
< blockquote class =post_quotes>我这样做:

strAccessPath = SysCmd(acSysCmdAccessDir)& msaccess.exe

在vb可执行文件中执行它的样子。

如果我删除对访问对象库的引用,这似乎是
是应用程序窒息的唯一一行。由于Access Obj库是最有可能位于非标准位置的库,我想知道如何在没有它的情况下做到这一点。我可以在上面进行后期绑定吗?




您可以使用FindExecutable API找出安装Access的位置
来自VB的
,而不依赖在任何外部库。

FindExecutable中存在一个错误,虽然有较长的名称(在较新的

操作系统中可能存在,也可能不存在),会在第一个空格后截断返回的路径。如果你需要

替代代码与FindExecutable做同样的事情,google for

FindExe2。


由于这种方法决定了文件可执行文件的路径

与之关联的扩展,当你在机器上安装了多个

版本的Access时,它可能会变得棘手。


-

删除9以通过电子邮件回复


" Terry Kreft" < TE ********* @ mps.co.uk>在消息中写道

新闻:-q ******************** @ karoo.co.uk ...

Mike,
SysCmd可以从Application对象中读取(以VB .exe形式)......

''************ *****************************
私人Const acSysCmdAccessDir = 9
私人子Command1_Click( )
将appAccess作为对象调暗
将strAccessPath作为字符串调暗

设置appAccess = CreateObject(" Access.Application")

strAccessPath = appAccess.SysCmd (acSysCmdAccessDir)& " msaccess.exe"

设置appAccess = Nothing
结束子

''**************** *************************

...无需参考Access即可使用。

太棒了,谢谢特里。正是我的意思。


事实证明,似乎没有任何区别。这是我做过的第一个VB的事情,所以经历了整个包装和部署

mullarkey。尝试使用设置例程进行安装,并对各种旧文件版本进行了各种各样的抗议活动。然后只是做了我的

实际exe文件的直接文件副本,它工作正常。即使我确定知道

Access OLB与我的不同。


这是一个前端更新程序,并且非常成功。大概

机器会在半夜自发燃烧,

只是为了擦掉我脸上的沾沾自喜的笑容。

否,后期绑定到所有对象是不可能的,但绝大多数
都可以。




值得做什么?据推测,像DAO和VB这样的运行时间都是标准的。


我从来没有真正理解所有这些东西。如果在我的开发机器上我

在c:\ myspecialinstallfolderthatonlyiknowabout \

中有一个库或一个dll而在客户端机器上有相同的库在

c:\ coompletelybogstandardplaceitusuallygoes \会不会一直粉碎应用程序?

或者是VB(在这种情况下)或者是一个智能足以环顾四周的Access应用程序
$ b如果它在第一个地方找不到它,那么就是g。


干杯,Mike MacSween


I''m doing this:

strAccessPath = SysCmd(acSysCmdAccessDir) & "msaccess.exe"

in a vb executable to do what it looks like.

If I remove the reference to the access object library this seems to be the
only line the app chokes on. As the Access Obj library is the one most
likely to be in a non-standard location I''m wondering how to do without it.
Can I make that above late binding?

In fact, is it possible to make all refs late binding? DAO, VB, VBA MS
Scripting etc.

Yours, Mike MacSween

解决方案

Mike,
SysCmd can be read from the Application object so (in a VB .exe form) ...

'' *****************************************
Private Const acSysCmdAccessDir = 9

Private Sub Command1_Click()
Dim appAccess As Object
Dim strAccessPath As String

Set appAccess = CreateObject("Access.Application")

strAccessPath = appAccess.SysCmd(acSysCmdAccessDir) & "msaccess.exe"

Set appAccess = Nothing
End Sub

'' *****************************************

.... works without a reference to Access.
No, it is not possible to late bind to all objects but the vast majority can
be.
--
Terry Kreft
MVP Microsoft Access
"Mike MacSween" <mi******************@btinternet.com> wrote in message
news:41***********************@news.aaisp.net.uk.. .

I''m doing this:

strAccessPath = SysCmd(acSysCmdAccessDir) & "msaccess.exe"

in a vb executable to do what it looks like.

If I remove the reference to the access object library this seems to be the only line the app chokes on. As the Access Obj library is the one most
likely to be in a non-standard location I''m wondering how to do without it. Can I make that above late binding?

In fact, is it possible to make all refs late binding? DAO, VB, VBA MS
Scripting etc.

Yours, Mike MacSween



On Jul 26 2004, 04:01 am, "Mike MacSween"
<mi******************@btinternet.com> wrote in
news:41***********************@news.aaisp.net.uk:

I''m doing this:

strAccessPath = SysCmd(acSysCmdAccessDir) & "msaccess.exe"

in a vb executable to do what it looks like.

If I remove the reference to the access object library this seems to
be the only line the app chokes on. As the Access Obj library is the
one most likely to be in a non-standard location I''m wondering how to
do without it. Can I make that above late binding?



You can use the FindExecutable API to find out where Access is installed
from VB, without depending on any external library. There is a bug in
FindExecutable with long names though (which may or may not exist in newer
OSes), that truncates the returned path after the first space. If you need
replacement code that does the same thing as FindExecutable, google for
FindExe2.

Since this approach determines the path to the executable by a file
extention associated with it, it may get tricky when you have multiple
versions of Access installed on the machine.

--
remove a 9 to reply by email


"Terry Kreft" <te*********@mps.co.uk> wrote in message
news:-q********************@karoo.co.uk...

Mike,
SysCmd can be read from the Application object so (in a VB .exe form) ...

'' *****************************************
Private Const acSysCmdAccessDir = 9

Private Sub Command1_Click()
Dim appAccess As Object
Dim strAccessPath As String

Set appAccess = CreateObject("Access.Application")

strAccessPath = appAccess.SysCmd(acSysCmdAccessDir) & "msaccess.exe"

Set appAccess = Nothing
End Sub

'' *****************************************

... works without a reference to Access.

Great, thanks Terry. Exactly what I meant.

As it turned out it didn''t seem to make any difference atall. This is the
first VB thing I''ve done, so went through the whole packaging and deployment
mullarkey. Tried to install using the set up routine and had all sorts of
protests about older file versions. Then just did a straight file copy of my
actual exe file and it worked fine. Even though I know for sure that the
Access OLB is in a different place to mine.

It''s a front end updater thing and was astonishingly successfull. Presumably
the machines are going to spontaneously combust in the middle of the night,
just to wipe the smug grin off my face.
No, it is not possible to late bind to all objects but the vast majority can be.



And is it worth doing? Presumably things like DAO and the VB run times all
go in a standard place.

I''ve never really understood all this stuff. If on my development machine I
have a library or a dll in c:\myspecialinstallfolderthatonlyiknowabout\
whereas on the clients machine the same library is in
c:\completelybogstandardplaceitusuallygoes\ does that always smash the app?
Or is VB (in this case) or an Access app smart enough to have a look around
the gaff if it doesn''t find it in the first place it looks in.

Cheers, Mike MacSween


这篇关于SysCmd作为后期绑定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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