简体   繁体   English

C#所需的HASP HL工作演示

[英]HASP HL working demo needed for C#

Okay. 好的。 Well, I know this question has a good chance of being closed within the first 10 minutes, but I am going to ask it anyways for I have spent almost day and an half trying to find a solution. 好吧,我知道这个问题很有可能在前10分钟内被关闭,但我还是会问它,因为我花了将近一天半的时间试图寻找解决方案。 Still, I can't figure this one out. 不过,我无法想出这个。 There is not much info on this on the Internet not even on the HASP (safenet) website although they have demos. 虽然他们有演示,但即使在HASP(safenet)网站上也没有太多关于此的信息。

I have a HASP HL USB dongle. 我有一个HASP HL USB加密狗。 I try to convert their demo and test run it but for the life of me I simply can't get it to login even. 我尝试转换他们的演示和测试运行它,但对于我的生活我甚至无法让它登录甚至。 It keeps raising Aladdin.HASP.HaspStatus.HaspDotNetDllBroken exception. 它不断提高Aladdin.HASP.HaspStatus.HaspDotNetDllBroken异常。

However, if I run the C version of their demo, it works perfectly. 但是,如果我运行他们演示的C版本,它可以很好地工作。

Here is the Csharp version of my code: 这是我的代码的Csharp版本:

Aladdin.HASP;
HASP myHasp = new HASP();
var thestatus = myHasp.Login(vender_code);
myHasp.Logout;

I would like to login to USB HASP and get its HaspID and the settings in its memory. 我想登录USB HASP并在其内存中获取其HaspID和设置。

Thanks in advance, 提前致谢,

It might be that you aren't having all dependencies for the HASP runtime. 可能是您没有HASP运行时的所有依赖项。 I'm packing with the app: 我正在打包应用程序:

hasp_windows_NNNNN.dll (NNNNN = your number)
hasp_net_windows.dll
MSVCR71.DLL (added manually)
msvc runtime 80

One runtime library is required by HASP and it doesn't tell you which one unless you put it in the DEPENDS.EXE utility (you probably have you on your Visual Studio installation). HASP需要一个运行时库,它不会告诉您哪一个,除非您将它放在DEPENDS.EXE实用程序中(您可能已安装Visual Studio)。

To log in (and read some bytes): 要登录(并读取一些字节):

            byte[] key = new byte[16];
            HaspFeature feature = HaspFeature.FromFeature(4);
            string vendorCode = "your vendor string, get it from your tools";
            Hasp hasp = new Hasp(feature);
            HaspStatus status = hasp.Login(vendorCode);
            if (HaspStatus.StatusOk != status)
            {
                //  no license to run
                return false;
            }
            else
            {
                //  read some memory here
                HaspFile mem = hasp.GetFile(HaspFileId.ReadOnly);
                mem.Read(key, 0, 16);
                status = hasp.Logout();
                if (HaspStatus.StatusOk != status)
                {
                    //handle error
                }
            }

Hope it helps. 希望能帮助到你。 My HASPed software works like a charm. 我的HASPed软件就像一个魅力。 BTW, wasn't able to put envelope around .NET app under no combination of settings. BTW,在没有设置组合的情况下无法在.NET应用程序周围放置信封。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM