Hikvision camera SDK [Delphi] - error 7 NET_DVR_NETWORK_FAIL_CONNECT












0















I cannot connect to hikvison camera, NET_DVR_Login_V30 returns -1, and NET_DVR_GetLastError returns 7:
"NET_DVR_NETWORK_FAIL_CONNECT - Connecting device failed. Device offline or network connection timed out."



Camera is 100% online and configured, I can successfully connect using ClientDemo.exe!



In wireshark I see that it don't even try to connect.



type
LPNET_DVR_DEVICEINFO_V30 = ^NET_DVR_DEVICEINFO_V30;

NET_DVR_DEVICEINFO_V30 = Record
sSerialNumber: array [0 .. 47] of BYTE;
byAlarmInPortNum: BYTE;
byAlarmOutPortNum: BYTE;
byDiskNum: BYTE;
byDVRType: BYTE;
byChanNum: BYTE;
byStartChan: BYTE;
byAudioChanNum: BYTE;
byIPChanNum: BYTE;
byZeroChanNum: BYTE;
byMainProto: BYTE;
bySubProto: BYTE;
bySupport: BYTE;
bySupport1: BYTE;
byRes1: BYTE;
wDevType: Word;
byRes2: array [0 .. 15] of BYTE;
end;

(...)

var
Form1: TForm1;
ErrorValues: LongWord;
lUserID: LONG;
struDeviceInfo: NET_DVR_DEVICEINFO_V30;
DVRIP, DVRUserName, DVRPassWord: String;


function NET_DVR_Init(): boolean; stdcall;
external 'HCNetSDK.dll' name 'NET_DVR_Init';

function NET_DVR_Cleanup(): boolean; stdcall;
external 'HCNetSDK.dll' name 'NET_DVR_Cleanup';

function NET_DVR_SetConnectTime(dwWaitTime, dwTryTimes: DWORD): boolean;
stdcall; external 'HCNetSDK.dll' name 'NET_DVR_SetConnectTime';

function NET_DVR_SetReconnect(dwInterval: DWORD; bEnableRecon: boolean)
: boolean; stdcall; external 'HCNetSDK.dll' name 'NET_DVR_SetReconnect';

function NET_DVR_GetLastError(): LongWord; stdcall;
external 'HCNetSDK.dll' name 'NET_DVR_GetLastError';

function NET_DVR_Login_V30(sDVRIP: PChar; wDVRPort: Word; sUserName: PChar;
sPassword: PChar; lpDeviceInfo: LPNET_DVR_DEVICEINFO_V30): LONG; stdcall;
external 'HCNetSDK.dll' name 'NET_DVR_Login_V30';

function NET_DVR_Logout_V30(lUserID: LONG): boolean; stdcall;
external 'HCNetSDK.dll' name 'NET_DVR_Logout_V30';


implementation

{$R *.dfm}


procedure TForm1.Button1Click(Sender: TObject);
begin
DVRIP := 'xxx.xxx.xxx.xxx';
DVRUserName := 'demo';
DVRPassWord := '12345';

NET_DVR_Init();

NET_DVR_SetConnectTime(2000, 1);
NET_DVR_SetReconnect(10000, true);

lUserID := NET_DVR_Login_V30(PChar(DVRIP), 8000, PChar(DVRUserName),
PChar(DVRPassWord), @struDeviceInfo);
Memo1.Lines.Add('lUserID:' + inttostr(lUserID));

ErrorValues := NET_DVR_GetLastError();
Memo1.Lines.Add('ErrorValues:' + inttostr(ErrorValues));

NET_DVR_Logout_V30(lUserID);
NET_DVR_Cleanup();

end;


Regards










share|improve this question




















  • 2





    Which Delphi Version do you use? Maybe you need to use PAnsiChar instead of PChar. I don't know the SDK.

    – G Wimpassinger
    Jan 3 at 13:56











  • Delphi 10.1 Berlin. PAnsiChar instead of PChar makes no difference. The above code found somewhere on the internet is quite old.

    – tomek
    Jan 3 at 14:22











  • Not familiar with the SDK but do you have an actual DVR setup? If not, maybe the API has a way to connect directly to the camera...

    – Alain Thiffault
    Jan 3 at 17:31











  • SDK consists of 2 dll's in it's basic form. I'm using the same dll's as ClientDemo that connects properly. Camera has an API over http and it works ok, but it has some drawbacks, so I'm trying with SDK.

    – tomek
    Jan 4 at 8:23













  • @GWimpassinger PAnsiChar was the key! One thing I didn't correct was declaration of variables from String to AnsiString. Thx.

    – tomek
    Jan 9 at 14:26
















0















I cannot connect to hikvison camera, NET_DVR_Login_V30 returns -1, and NET_DVR_GetLastError returns 7:
"NET_DVR_NETWORK_FAIL_CONNECT - Connecting device failed. Device offline or network connection timed out."



Camera is 100% online and configured, I can successfully connect using ClientDemo.exe!



In wireshark I see that it don't even try to connect.



type
LPNET_DVR_DEVICEINFO_V30 = ^NET_DVR_DEVICEINFO_V30;

NET_DVR_DEVICEINFO_V30 = Record
sSerialNumber: array [0 .. 47] of BYTE;
byAlarmInPortNum: BYTE;
byAlarmOutPortNum: BYTE;
byDiskNum: BYTE;
byDVRType: BYTE;
byChanNum: BYTE;
byStartChan: BYTE;
byAudioChanNum: BYTE;
byIPChanNum: BYTE;
byZeroChanNum: BYTE;
byMainProto: BYTE;
bySubProto: BYTE;
bySupport: BYTE;
bySupport1: BYTE;
byRes1: BYTE;
wDevType: Word;
byRes2: array [0 .. 15] of BYTE;
end;

(...)

var
Form1: TForm1;
ErrorValues: LongWord;
lUserID: LONG;
struDeviceInfo: NET_DVR_DEVICEINFO_V30;
DVRIP, DVRUserName, DVRPassWord: String;


function NET_DVR_Init(): boolean; stdcall;
external 'HCNetSDK.dll' name 'NET_DVR_Init';

function NET_DVR_Cleanup(): boolean; stdcall;
external 'HCNetSDK.dll' name 'NET_DVR_Cleanup';

function NET_DVR_SetConnectTime(dwWaitTime, dwTryTimes: DWORD): boolean;
stdcall; external 'HCNetSDK.dll' name 'NET_DVR_SetConnectTime';

function NET_DVR_SetReconnect(dwInterval: DWORD; bEnableRecon: boolean)
: boolean; stdcall; external 'HCNetSDK.dll' name 'NET_DVR_SetReconnect';

function NET_DVR_GetLastError(): LongWord; stdcall;
external 'HCNetSDK.dll' name 'NET_DVR_GetLastError';

function NET_DVR_Login_V30(sDVRIP: PChar; wDVRPort: Word; sUserName: PChar;
sPassword: PChar; lpDeviceInfo: LPNET_DVR_DEVICEINFO_V30): LONG; stdcall;
external 'HCNetSDK.dll' name 'NET_DVR_Login_V30';

function NET_DVR_Logout_V30(lUserID: LONG): boolean; stdcall;
external 'HCNetSDK.dll' name 'NET_DVR_Logout_V30';


implementation

{$R *.dfm}


procedure TForm1.Button1Click(Sender: TObject);
begin
DVRIP := 'xxx.xxx.xxx.xxx';
DVRUserName := 'demo';
DVRPassWord := '12345';

NET_DVR_Init();

NET_DVR_SetConnectTime(2000, 1);
NET_DVR_SetReconnect(10000, true);

lUserID := NET_DVR_Login_V30(PChar(DVRIP), 8000, PChar(DVRUserName),
PChar(DVRPassWord), @struDeviceInfo);
Memo1.Lines.Add('lUserID:' + inttostr(lUserID));

ErrorValues := NET_DVR_GetLastError();
Memo1.Lines.Add('ErrorValues:' + inttostr(ErrorValues));

NET_DVR_Logout_V30(lUserID);
NET_DVR_Cleanup();

end;


Regards










share|improve this question




















  • 2





    Which Delphi Version do you use? Maybe you need to use PAnsiChar instead of PChar. I don't know the SDK.

    – G Wimpassinger
    Jan 3 at 13:56











  • Delphi 10.1 Berlin. PAnsiChar instead of PChar makes no difference. The above code found somewhere on the internet is quite old.

    – tomek
    Jan 3 at 14:22











  • Not familiar with the SDK but do you have an actual DVR setup? If not, maybe the API has a way to connect directly to the camera...

    – Alain Thiffault
    Jan 3 at 17:31











  • SDK consists of 2 dll's in it's basic form. I'm using the same dll's as ClientDemo that connects properly. Camera has an API over http and it works ok, but it has some drawbacks, so I'm trying with SDK.

    – tomek
    Jan 4 at 8:23













  • @GWimpassinger PAnsiChar was the key! One thing I didn't correct was declaration of variables from String to AnsiString. Thx.

    – tomek
    Jan 9 at 14:26














0












0








0








I cannot connect to hikvison camera, NET_DVR_Login_V30 returns -1, and NET_DVR_GetLastError returns 7:
"NET_DVR_NETWORK_FAIL_CONNECT - Connecting device failed. Device offline or network connection timed out."



Camera is 100% online and configured, I can successfully connect using ClientDemo.exe!



In wireshark I see that it don't even try to connect.



type
LPNET_DVR_DEVICEINFO_V30 = ^NET_DVR_DEVICEINFO_V30;

NET_DVR_DEVICEINFO_V30 = Record
sSerialNumber: array [0 .. 47] of BYTE;
byAlarmInPortNum: BYTE;
byAlarmOutPortNum: BYTE;
byDiskNum: BYTE;
byDVRType: BYTE;
byChanNum: BYTE;
byStartChan: BYTE;
byAudioChanNum: BYTE;
byIPChanNum: BYTE;
byZeroChanNum: BYTE;
byMainProto: BYTE;
bySubProto: BYTE;
bySupport: BYTE;
bySupport1: BYTE;
byRes1: BYTE;
wDevType: Word;
byRes2: array [0 .. 15] of BYTE;
end;

(...)

var
Form1: TForm1;
ErrorValues: LongWord;
lUserID: LONG;
struDeviceInfo: NET_DVR_DEVICEINFO_V30;
DVRIP, DVRUserName, DVRPassWord: String;


function NET_DVR_Init(): boolean; stdcall;
external 'HCNetSDK.dll' name 'NET_DVR_Init';

function NET_DVR_Cleanup(): boolean; stdcall;
external 'HCNetSDK.dll' name 'NET_DVR_Cleanup';

function NET_DVR_SetConnectTime(dwWaitTime, dwTryTimes: DWORD): boolean;
stdcall; external 'HCNetSDK.dll' name 'NET_DVR_SetConnectTime';

function NET_DVR_SetReconnect(dwInterval: DWORD; bEnableRecon: boolean)
: boolean; stdcall; external 'HCNetSDK.dll' name 'NET_DVR_SetReconnect';

function NET_DVR_GetLastError(): LongWord; stdcall;
external 'HCNetSDK.dll' name 'NET_DVR_GetLastError';

function NET_DVR_Login_V30(sDVRIP: PChar; wDVRPort: Word; sUserName: PChar;
sPassword: PChar; lpDeviceInfo: LPNET_DVR_DEVICEINFO_V30): LONG; stdcall;
external 'HCNetSDK.dll' name 'NET_DVR_Login_V30';

function NET_DVR_Logout_V30(lUserID: LONG): boolean; stdcall;
external 'HCNetSDK.dll' name 'NET_DVR_Logout_V30';


implementation

{$R *.dfm}


procedure TForm1.Button1Click(Sender: TObject);
begin
DVRIP := 'xxx.xxx.xxx.xxx';
DVRUserName := 'demo';
DVRPassWord := '12345';

NET_DVR_Init();

NET_DVR_SetConnectTime(2000, 1);
NET_DVR_SetReconnect(10000, true);

lUserID := NET_DVR_Login_V30(PChar(DVRIP), 8000, PChar(DVRUserName),
PChar(DVRPassWord), @struDeviceInfo);
Memo1.Lines.Add('lUserID:' + inttostr(lUserID));

ErrorValues := NET_DVR_GetLastError();
Memo1.Lines.Add('ErrorValues:' + inttostr(ErrorValues));

NET_DVR_Logout_V30(lUserID);
NET_DVR_Cleanup();

end;


Regards










share|improve this question
















I cannot connect to hikvison camera, NET_DVR_Login_V30 returns -1, and NET_DVR_GetLastError returns 7:
"NET_DVR_NETWORK_FAIL_CONNECT - Connecting device failed. Device offline or network connection timed out."



Camera is 100% online and configured, I can successfully connect using ClientDemo.exe!



In wireshark I see that it don't even try to connect.



type
LPNET_DVR_DEVICEINFO_V30 = ^NET_DVR_DEVICEINFO_V30;

NET_DVR_DEVICEINFO_V30 = Record
sSerialNumber: array [0 .. 47] of BYTE;
byAlarmInPortNum: BYTE;
byAlarmOutPortNum: BYTE;
byDiskNum: BYTE;
byDVRType: BYTE;
byChanNum: BYTE;
byStartChan: BYTE;
byAudioChanNum: BYTE;
byIPChanNum: BYTE;
byZeroChanNum: BYTE;
byMainProto: BYTE;
bySubProto: BYTE;
bySupport: BYTE;
bySupport1: BYTE;
byRes1: BYTE;
wDevType: Word;
byRes2: array [0 .. 15] of BYTE;
end;

(...)

var
Form1: TForm1;
ErrorValues: LongWord;
lUserID: LONG;
struDeviceInfo: NET_DVR_DEVICEINFO_V30;
DVRIP, DVRUserName, DVRPassWord: String;


function NET_DVR_Init(): boolean; stdcall;
external 'HCNetSDK.dll' name 'NET_DVR_Init';

function NET_DVR_Cleanup(): boolean; stdcall;
external 'HCNetSDK.dll' name 'NET_DVR_Cleanup';

function NET_DVR_SetConnectTime(dwWaitTime, dwTryTimes: DWORD): boolean;
stdcall; external 'HCNetSDK.dll' name 'NET_DVR_SetConnectTime';

function NET_DVR_SetReconnect(dwInterval: DWORD; bEnableRecon: boolean)
: boolean; stdcall; external 'HCNetSDK.dll' name 'NET_DVR_SetReconnect';

function NET_DVR_GetLastError(): LongWord; stdcall;
external 'HCNetSDK.dll' name 'NET_DVR_GetLastError';

function NET_DVR_Login_V30(sDVRIP: PChar; wDVRPort: Word; sUserName: PChar;
sPassword: PChar; lpDeviceInfo: LPNET_DVR_DEVICEINFO_V30): LONG; stdcall;
external 'HCNetSDK.dll' name 'NET_DVR_Login_V30';

function NET_DVR_Logout_V30(lUserID: LONG): boolean; stdcall;
external 'HCNetSDK.dll' name 'NET_DVR_Logout_V30';


implementation

{$R *.dfm}


procedure TForm1.Button1Click(Sender: TObject);
begin
DVRIP := 'xxx.xxx.xxx.xxx';
DVRUserName := 'demo';
DVRPassWord := '12345';

NET_DVR_Init();

NET_DVR_SetConnectTime(2000, 1);
NET_DVR_SetReconnect(10000, true);

lUserID := NET_DVR_Login_V30(PChar(DVRIP), 8000, PChar(DVRUserName),
PChar(DVRPassWord), @struDeviceInfo);
Memo1.Lines.Add('lUserID:' + inttostr(lUserID));

ErrorValues := NET_DVR_GetLastError();
Memo1.Lines.Add('ErrorValues:' + inttostr(ErrorValues));

NET_DVR_Logout_V30(lUserID);
NET_DVR_Cleanup();

end;


Regards







delphi hikvision






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 3 at 13:45







tomek

















asked Jan 3 at 13:39









tomektomek

82




82








  • 2





    Which Delphi Version do you use? Maybe you need to use PAnsiChar instead of PChar. I don't know the SDK.

    – G Wimpassinger
    Jan 3 at 13:56











  • Delphi 10.1 Berlin. PAnsiChar instead of PChar makes no difference. The above code found somewhere on the internet is quite old.

    – tomek
    Jan 3 at 14:22











  • Not familiar with the SDK but do you have an actual DVR setup? If not, maybe the API has a way to connect directly to the camera...

    – Alain Thiffault
    Jan 3 at 17:31











  • SDK consists of 2 dll's in it's basic form. I'm using the same dll's as ClientDemo that connects properly. Camera has an API over http and it works ok, but it has some drawbacks, so I'm trying with SDK.

    – tomek
    Jan 4 at 8:23













  • @GWimpassinger PAnsiChar was the key! One thing I didn't correct was declaration of variables from String to AnsiString. Thx.

    – tomek
    Jan 9 at 14:26














  • 2





    Which Delphi Version do you use? Maybe you need to use PAnsiChar instead of PChar. I don't know the SDK.

    – G Wimpassinger
    Jan 3 at 13:56











  • Delphi 10.1 Berlin. PAnsiChar instead of PChar makes no difference. The above code found somewhere on the internet is quite old.

    – tomek
    Jan 3 at 14:22











  • Not familiar with the SDK but do you have an actual DVR setup? If not, maybe the API has a way to connect directly to the camera...

    – Alain Thiffault
    Jan 3 at 17:31











  • SDK consists of 2 dll's in it's basic form. I'm using the same dll's as ClientDemo that connects properly. Camera has an API over http and it works ok, but it has some drawbacks, so I'm trying with SDK.

    – tomek
    Jan 4 at 8:23













  • @GWimpassinger PAnsiChar was the key! One thing I didn't correct was declaration of variables from String to AnsiString. Thx.

    – tomek
    Jan 9 at 14:26








2




2





Which Delphi Version do you use? Maybe you need to use PAnsiChar instead of PChar. I don't know the SDK.

– G Wimpassinger
Jan 3 at 13:56





Which Delphi Version do you use? Maybe you need to use PAnsiChar instead of PChar. I don't know the SDK.

– G Wimpassinger
Jan 3 at 13:56













Delphi 10.1 Berlin. PAnsiChar instead of PChar makes no difference. The above code found somewhere on the internet is quite old.

– tomek
Jan 3 at 14:22





Delphi 10.1 Berlin. PAnsiChar instead of PChar makes no difference. The above code found somewhere on the internet is quite old.

– tomek
Jan 3 at 14:22













Not familiar with the SDK but do you have an actual DVR setup? If not, maybe the API has a way to connect directly to the camera...

– Alain Thiffault
Jan 3 at 17:31





Not familiar with the SDK but do you have an actual DVR setup? If not, maybe the API has a way to connect directly to the camera...

– Alain Thiffault
Jan 3 at 17:31













SDK consists of 2 dll's in it's basic form. I'm using the same dll's as ClientDemo that connects properly. Camera has an API over http and it works ok, but it has some drawbacks, so I'm trying with SDK.

– tomek
Jan 4 at 8:23







SDK consists of 2 dll's in it's basic form. I'm using the same dll's as ClientDemo that connects properly. Camera has an API over http and it works ok, but it has some drawbacks, so I'm trying with SDK.

– tomek
Jan 4 at 8:23















@GWimpassinger PAnsiChar was the key! One thing I didn't correct was declaration of variables from String to AnsiString. Thx.

– tomek
Jan 9 at 14:26





@GWimpassinger PAnsiChar was the key! One thing I didn't correct was declaration of variables from String to AnsiString. Thx.

– tomek
Jan 9 at 14:26












1 Answer
1






active

oldest

votes


















0














To make it work the original code need 2 fixes:

1. Correct variable declarations from String to AnsiString

2. Pass strings to dll as PAnsiChar (as G Wimpassinger pointed)



DVRIP, DVRUserName, DVRPassWord: AnsiString;
...

function NET_DVR_Login_V30(sDVRIP: PAnsiChar; wDVRPort: Word; sUserName: PAnsiChar;
sPassword: PAnsiChar; lpDeviceInfo: LPNET_DVR_DEVICEINFO_V30): LONG; stdcall;
external 'HCNetSDK.dll' name 'NET_DVR_Login_V30';
...

lUserID := NET_DVR_Login_V30(PAnsiChar(DVRIP), 8000, PAnsiChar(DVRUserName),
PAnsiChar(DVRPassWord), @struDeviceInfo);





share|improve this answer
























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54023444%2fhikvision-camera-sdk-delphi-error-7-net-dvr-network-fail-connect%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    To make it work the original code need 2 fixes:

    1. Correct variable declarations from String to AnsiString

    2. Pass strings to dll as PAnsiChar (as G Wimpassinger pointed)



    DVRIP, DVRUserName, DVRPassWord: AnsiString;
    ...

    function NET_DVR_Login_V30(sDVRIP: PAnsiChar; wDVRPort: Word; sUserName: PAnsiChar;
    sPassword: PAnsiChar; lpDeviceInfo: LPNET_DVR_DEVICEINFO_V30): LONG; stdcall;
    external 'HCNetSDK.dll' name 'NET_DVR_Login_V30';
    ...

    lUserID := NET_DVR_Login_V30(PAnsiChar(DVRIP), 8000, PAnsiChar(DVRUserName),
    PAnsiChar(DVRPassWord), @struDeviceInfo);





    share|improve this answer




























      0














      To make it work the original code need 2 fixes:

      1. Correct variable declarations from String to AnsiString

      2. Pass strings to dll as PAnsiChar (as G Wimpassinger pointed)



      DVRIP, DVRUserName, DVRPassWord: AnsiString;
      ...

      function NET_DVR_Login_V30(sDVRIP: PAnsiChar; wDVRPort: Word; sUserName: PAnsiChar;
      sPassword: PAnsiChar; lpDeviceInfo: LPNET_DVR_DEVICEINFO_V30): LONG; stdcall;
      external 'HCNetSDK.dll' name 'NET_DVR_Login_V30';
      ...

      lUserID := NET_DVR_Login_V30(PAnsiChar(DVRIP), 8000, PAnsiChar(DVRUserName),
      PAnsiChar(DVRPassWord), @struDeviceInfo);





      share|improve this answer


























        0












        0








        0







        To make it work the original code need 2 fixes:

        1. Correct variable declarations from String to AnsiString

        2. Pass strings to dll as PAnsiChar (as G Wimpassinger pointed)



        DVRIP, DVRUserName, DVRPassWord: AnsiString;
        ...

        function NET_DVR_Login_V30(sDVRIP: PAnsiChar; wDVRPort: Word; sUserName: PAnsiChar;
        sPassword: PAnsiChar; lpDeviceInfo: LPNET_DVR_DEVICEINFO_V30): LONG; stdcall;
        external 'HCNetSDK.dll' name 'NET_DVR_Login_V30';
        ...

        lUserID := NET_DVR_Login_V30(PAnsiChar(DVRIP), 8000, PAnsiChar(DVRUserName),
        PAnsiChar(DVRPassWord), @struDeviceInfo);





        share|improve this answer













        To make it work the original code need 2 fixes:

        1. Correct variable declarations from String to AnsiString

        2. Pass strings to dll as PAnsiChar (as G Wimpassinger pointed)



        DVRIP, DVRUserName, DVRPassWord: AnsiString;
        ...

        function NET_DVR_Login_V30(sDVRIP: PAnsiChar; wDVRPort: Word; sUserName: PAnsiChar;
        sPassword: PAnsiChar; lpDeviceInfo: LPNET_DVR_DEVICEINFO_V30): LONG; stdcall;
        external 'HCNetSDK.dll' name 'NET_DVR_Login_V30';
        ...

        lUserID := NET_DVR_Login_V30(PAnsiChar(DVRIP), 8000, PAnsiChar(DVRUserName),
        PAnsiChar(DVRPassWord), @struDeviceInfo);






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 9 at 14:46









        tomektomek

        82




        82
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54023444%2fhikvision-camera-sdk-delphi-error-7-net-dvr-network-fail-connect%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Monofisismo

            Angular Downloading a file using contenturl with Basic Authentication

            Olmecas