| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1359 人关注过本帖
标题:C语句如何对应Delphi语句
只看楼主 加入收藏
wbjj_plus
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2012-10-17
结帖率:0
收藏
已结贴  问题点数:20 回复次数:10 
C语句如何对应Delphi语句
C语句如何对应Delphi语句

WINAPI EEoSetOsdDisplayMode(DWORD dwChannel, DWORD color, DWORD font_size, USHORT* Line1, USHORT* Line2, BOOL bAutoLight=FALSE)
USHORT osdFormat1[] = {0,0, OSD_Year4, '-', OSD_Month2, '-', OSD_Day, ' ',  
OSD_Hour12, ':', OSD_Minute, ':', OSD_Second, ' ', 0};
USHORT osdFormat2[] = {0, 0, '0','0, '0, '0', '0', '0',0};

-----------------------------
请问上面语句在Delphi中如何对应?特别是USHORT*,在delphi中不知道如何对应?
谢谢!
搜索更多相关主题的帖子: 如何 特别 color delphi 
2012-10-17 16:04
wp231957
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:神界
等 级:贵宾
威 望:423
帖 子:13688
专家分:53332
注 册:2012-10-18
收藏
得分:0 
大概百度到的这个帖子都是楼主发的吧  

如果是单纯的把C代码翻译成D代码  是很难的  

有些时候C--d 并没有对应关系

DO IT YOURSELF !
2012-10-18 10:24
wbjj_plus
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2012-10-17
收藏
得分:0 
回复 2楼 wp231957
已经定义了,可是不正确。
帮忙看下下面的哪里出问题了?谢谢!

************************************
Function(dwChannel,color,font_size : longint; Line1 ,Line2 : PWORD) : integer;stdcall;

VAR
  fData1 : PWORD ;
  fData2 : PWORD ;
  PSdk4000Func := GetProcAddress(FSdk4000Func,'EEoSetOsdDisplayMode') ;
  if PSdk4000Func <> nil then begin
  FunEEoSetOsdDisplayMode := TEEoSetOsdDisplayMode(PSdk4000Func);
  GetMem(fData2,sizeof(WORD) * 20) ;
  fData2^ := WindowFirIn.Height + 5 ;
  INC(fData2) ;
  fData2^ := WindowFirIn.Left + 5 ;
  INC(fData2) ;
  fData2^ := $BDF8 ;
  INC(fData2) ;
  fData2^ := $BDF8 ;
  INC(fData2) ;
  fData2^ := $BDF8 ;
  INC(fData2) ;
  fData2^ := $BDF8 ;
  INC(fData2) ;
  fData2^ := 0 ;
  iRet := FunEEoSetOsdDisplayMode(iTV1,10,80,fData2,fData2) ;
  //FreeMem(fData2) ;
  end;
******************************************
2012-10-18 10:34
wp231957
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:神界
等 级:贵宾
威 望:423
帖 子:13688
专家分:53332
注 册:2012-10-18
收藏
得分:0 
感觉 USHORT* Line1  应该是一个指向无符号短整型的指针  你直接定义为LONGINT 应该不行

DO IT YOURSELF !
2012-10-18 10:43
wbjj_plus
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2012-10-17
收藏
得分:0 
是个双字节指针
2012-10-18 12:22
wp231957
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:神界
等 级:贵宾
威 望:423
帖 子:13688
专家分:53332
注 册:2012-10-18
收藏
得分:0 
以下是引用wp231957在2012-10-18 10:43:15的发言:

感觉 USHORT* Line1  应该是一个指向无符号短整型的指针  你直接定义为LONGINT 应该不可以
看差函数参数了   不好意思了

DO IT YOURSELF !
2012-10-18 12:36
wp231957
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:神界
等 级:贵宾
威 望:423
帖 子:13688
专家分:53332
注 册:2012-10-18
收藏
得分:0 
以下是引用wbjj_plus在2012-10-18 10:34:15的发言:

已经定义了,可是不正确。
帮忙看下下面的哪里出问题了?谢谢!

************************************
Function(dwChannel,color,font_size : longint; Line1 ,Line2 : PWORD) : integer;stdcall;

VAR
  fData1 : PWORD ;
  fData2 : PWORD ;
  PSdk4000Func := GetProcAddress(FSdk4000Func,'EEoSetOsdDisplayMode') ;
  if PSdk4000Func <> nil then begin
  FunEEoSetOsdDisplayMode := TEEoSetOsdDisplayMode(PSdk4000Func);
  GetMem(fData2,sizeof(WORD) * 20) ;
  fData2^ := WindowFirIn.Height + 5 ;
  INC(fData2) ;
  fData2^ := WindowFirIn.Left + 5 ;
  INC(fData2) ;
  fData2^ := $BDF8 ;
  INC(fData2) ;
  fData2^ := $BDF8 ;
  INC(fData2) ;
  fData2^ := $BDF8 ;
  INC(fData2) ;
  fData2^ := $BDF8 ;
  INC(fData2) ;
  fData2^ := 0 ;
  iRet := FunEEoSetOsdDisplayMode(iTV1,10,80,fData2,fData2) ;
  //FreeMem(fData2) ;
  end;
******************************************
你这没有上下文,很多变量都不知道是在哪定义的呢

DO IT YOURSELF !
2012-10-18 13:09
wbjj_plus
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2012-10-17
收藏
得分:0 
这是C程序:
**************************
int CEEoServerDlg::Init()
{
    int       nRet = 0;
    DWORD  i;
//    USHORT osdFormat1[] = {0,0, OSD_Year4, '-', OSD_Month2, '-', OSD_Day, ' ',
                           //OSD_Hour12, ':', OSD_Minute, ':', OSD_Second, ' ', 0};
//    USHORT osdFormat1[] = {0,0, 0, 0, 0, 0,0, 0,
//                           0, 0, 0, 0,0, 0, 0};

    USHORT osdFormat1[] = {0,0, 0};
    USHORT osdFormat2[] = {0, 0, '0','0', '0', 0, '0', '0',0};
    char   szChannel[20];

    GetWindowRect(&m_rcParent);

    if(!MTALoadLibrary(5000, WORK_AS_SERVER))
    {
        AfxMessageBox("To initialize net work sdk failed!");
    }
    else
    {
        if(!MTARegNotifier(&NetNotifierProc))
            AfxMessageBox("To register net work notifier callback function failed!");
    }
 
    nRet = EEoInit();   
    if(nRet >= 0)
    {
        m_dwVideos = EEoGetTotalChannels();
        if(m_dwVideos > 0)
        {
            DWORD  k = m_dwVideos;
            int    nWidth, nHeight;
            CRect rcClient;

            EEoEnableOverlay(FALSE);

            CreateButtons();
            EEoSetVideoStandard(VS_PAL_BDGHI);//VS_NTSC
        //    for(i=0; i<m_dwVideos; i++)
        /*    EEoSetCaptureSize(0, 352, 288);    // EEoSetCaptureSize(352, 288);
            EEoSetCaptureSize(1, 704, 576);     
            EEoSetCaptureSize(2, 704, 576);   
            EEoSetCaptureSize(3, 704, 576);*/
        //    EEoSetCaptureSize(704, 576);   
            EEoSetVideoFormat(VF_YUY2);
            
            m_VideoWnds = new CVideoWnd[m_dwVideos];
            GetClientRect(&rcClient);
            
            if(k>3)
                k= (DWORD) sqrt((float)m_dwVideos);
            if(k*k<m_dwVideos)
                k= k+1;

            nWidth = (rcClient.Width() - 200) / k;
            nHeight= (rcClient.Height()- 50)  / k;

            EEoSetCaptureSize(/*704, 576*/352, 288);
            for(i=0; i<m_dwVideos; i++)
            {
                rcClient.left  = 1 + nWidth*(i%k);
                rcClient.top   = 1 + nHeight*(i/k);
                rcClient.right = rcClient.left + nWidth - 1;
                rcClient.bottom= rcClient.top + nHeight - 1;
                m_VideoWnds[i].SetVideoIndex(i);
                m_VideoWnds[i].Create(rcClient, this);
                m_VideoWnds[i].GetClientRect(&rcClient);
               
            //    EEoSetCaptureSize(i, 704, 576);
//                if(i % 4 == 1)
//                {
//                    EEoSetCaptureSize(i, 640, 480);
//                    osdFormat2[0] = 640 - 85;
//                    osdFormat2[1] = 480 - 34;
//                }
//                else
                {
                    osdFormat2[0] = 352 - 55;
                    osdFormat2[1] = 240 - 10;
                }
                wsprintf(szChannel, "%02d", i+1);
                //osdFormat2[4] = szChannel[0];
                //osdFormat2[5] = szChannel[1];
                DWORD ki= EEoGetVideoSignal(i);
                {
                    EEoSetFrameRate(i, 25);
                    EEoOpenChannel(i);
            //        EEoAssignFrameRate();
                    EEoSetEncoderParam(i, 1024000, 25);
                    EEoStartVideoPreview(i, m_VideoWnds[i].GetSafeHwnd(),&rcClient);
                }
            //    else
                {
            //        EEoCloseChannel(i);
                }

                EEoSetupMotionDetection(i, 5, MotionAnalyzerProc, this);
            
                //EEoSetOsdDisplayMode(i, RGB(255,255,255), /*(i%4 == 1) ? 32:*/50, osdFormat1, osdFormat2);
            
                EEoSetOsdDisplayMode(i, 255, /*(i%4 == 1) ? 32:*/50, osdFormat1, osdFormat2);

                EEoSetOsd(i, 1);
                EEoRegisterVideoStreamCallback(i, VideoStreamProc);
                EEoRegisterVideoRawDataCallback(i, VideoRawStreamProc);

            //    EEoRegisterAudioStreamCallback(i, AudioStreamProc);
            //    EEoStopVideoPreview(i);
                ((CButton*)GetDlgItem(IDC_CHK_PREVIEW+i))->SetCheck(TRUE);
            }
            m_VideoWnds[0].GetWindowRect(&m_rcLarge);
            m_rcLarge.right = m_rcLarge.left + nWidth*k - 11;
            m_rcLarge.bottom= m_rcLarge.top + nHeight*k - 11;
            ScreenToClient(&m_rcLarge);

            m_dwAudio= EEoGetAudioDevNum();

            for(i= 0; i<m_dwAudio; i++)
            {
                EEoRegisterAudioStreamCallback(i, AudioStreamProc);
            }
        }
        /*else
        {
            GetDlgItem(IDC_BTN_START_RECORD_ALL)->EnableWindow(FALSE);
            GetDlgItem(IDC_BTN_STOP_RECORD_ALL)->EnableWindow(FALSE);
        }*/
    }
    else
    {
        GetDlgItem(IDC_BTN_START_RECORD_ALL)->EnableWindow(FALSE);
        GetDlgItem(IDC_BTN_STOP_RECORD_ALL)->EnableWindow(FALSE);
        GetDlgItem(IDC_BTN_DEFAULT)->EnableWindow(FALSE);
        m_sldBright.EnableWindow(FALSE);
        m_sldContrast.EnableWindow(FALSE);
        m_sldHue.EnableWindow(FALSE);
        m_sldSaturation.EnableWindow(FALSE);
        GetDlgItem(IDC_BTN_SNAP)->EnableWindow(FALSE);
        GetDlgItem(IDC_CHK_MOTION_DETECT)->EnableWindow(FALSE);
        GetDlgItem(IDC_CHK_OSD)->EnableWindow(FALSE);
    }


//    EEoStartCaptureFile(0, "c:\\Videos\\0Video.avi");
//    CFCreate();   

    return nRet;
}
int   WINAPI EEoSetOsdDisplayMode(DWORD dwChannel, DWORD color, DWORD font_size, USHORT* Line1, USHORT* Line2);
*********************************


下面的是Delphi的函数定义:
 TEEoSetOsdDisplayMode   = Function(dwChannel,color,font_size : longint; Line1 ,Line2 : PInteger) : integer;stdcall;
 
下面是Delphi源程序:
var
  iRet,rTV1,rTV2,iCount,oCount : integer;
  sSQL : string ;
  fData1 : PWORD ;
  fData2 : PWORD ;
begin
      PSdk4000Func := GetProcAddress(FSdk4000Func,'EEoSetOsdDisplayMode') ;
      if PSdk4000Func <> nil then begin
        FunEEoSetOsdDisplayMode := TEEoSetOsdDisplayMode(PSdk4000Func);
        GetMem(fData1,SizeOf(PWORD)*10) ;
        fData1^ := 0 ;
        INC(fData1,2)  ;
        fData1^ := 0 ;
        INC(fData1,2) ;
        fData1^ := 0 ;
        //FreeMem(fData1) ;

        //GetMem(fData2,SizeOf(WORD)*100) ;
        GetMemory(SizeOf(fData2)*100);
        fData2^ :=  0 ;
        INC(fData2) ;
        fData2^ := 0 ;
        INC(fData2) ;
        fData2^ := $BDF8 ;
        INC(fData2) ;
        fData2^ := $BDF8 ;
        INC(fData2) ;
        fData2^ := $BDF8 ;
        INC(fData2) ;
        fData2^ := $BDF8 ;
        INC(fData2) ;
        fData2^ := 0 ;
        iRet := FunEEoSetOsdDisplayMode(iTV1,10,80,@fData1,@fData1) ;
        FreeMem(fData1,SizeOf(WORD)*100) ;
        FreeMem(fData2,SizeOf(WORD)*100) ;
      end;
end;

*********************************************************
这个函数USHORT*在Delphi中如何对应?
帮忙看下我上面的定义错在哪里?
编译可以通过,运行出虚拟地址错误。
2012-10-18 16:11
wp231957
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:神界
等 级:贵宾
威 望:423
帖 子:13688
专家分:53332
注 册:2012-10-18
收藏
得分:10 
FSdk4000Func  我没看到你在哪里赋值  这个应该是取自某DLL的句柄吧

DO IT YOURSELF !
2012-10-19 08:24
wp231957
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:神界
等 级:贵宾
威 望:423
帖 子:13688
专家分:53332
注 册:2012-10-18
收藏
得分:0 
FunEEoSetOsdDisplayMode(iTV1  这里的ITV1也没看到在哪里取数

DO IT YOURSELF !
2012-10-19 08:33
快速回复:C语句如何对应Delphi语句
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017567 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved