PrintQueue.StartTimeOfDay 属性

定义

获取或设置打印机在一天中开始打印作业的最早时间,用协调世界时 (UTC)(也称格林尼治标准时间 [GMT])午夜过后的分钟数表示。

public:
 virtual property int StartTimeOfDay { int get(); void set(int value); };
public virtual int StartTimeOfDay { get; set; }
member this.StartTimeOfDay : int with get, set
Public Overridable Property StartTimeOfDay As Integer

属性值

Int32

打印机在一天中的最早工作时间,用午夜 (UTC) 后的分钟数表示。 最大值为 1439。 首次使用 Microsoft Windows添加打印机向导安装打印机时,打印机默认为随时可用,并且此属性在所有时区中返回 0。

示例

以下示例演示如何使用此属性来确定打印机目前是否可用。

private: 
   static void ReportAvailabilityAtThisTime (System::String^% statusReport, System::Printing::PrintQueue^ pq) 
   {
      if (pq->StartTimeOfDay != pq->UntilTimeOfDay)
      {
         System::DateTime utcNow = DateTime::UtcNow;
         System::Int32 utcNowAsMinutesAfterMidnight = (utcNow.TimeOfDay.Hours * 60) + utcNow.TimeOfDay.Minutes;

         // If now is not within the range of available times . . .
         if (!((pq->StartTimeOfDay < utcNowAsMinutesAfterMidnight) && (utcNowAsMinutesAfterMidnight < pq->UntilTimeOfDay)))
         {
            statusReport = statusReport + " Is not available at this time of day. ";
         }
      }
   };
private static void ReportAvailabilityAtThisTime(ref String statusReport, PrintQueue pq)
{
    if (pq.StartTimeOfDay != pq.UntilTimeOfDay) // If the printer is not available 24 hours a day
    {
DateTime utcNow = DateTime.UtcNow;
Int32 utcNowAsMinutesAfterMidnight = (utcNow.TimeOfDay.Hours * 60) + utcNow.TimeOfDay.Minutes;
        
        // If now is not within the range of available times . . .
        if (!((pq.StartTimeOfDay < utcNowAsMinutesAfterMidnight) 
           &&
           (utcNowAsMinutesAfterMidnight < pq.UntilTimeOfDay)))
        {
            statusReport = statusReport + " Is not available at this time of day. ";
        }
    }
}
Private Shared Sub ReportAvailabilityAtThisTime(ByRef statusReport As String, ByVal pq As PrintQueue)
    If pq.StartTimeOfDay <> pq.UntilTimeOfDay Then ' If the printer is not available 24 hours a day
Dim utcNow As Date = Date.UtcNow
Dim utcNowAsMinutesAfterMidnight As Int32 = (utcNow.TimeOfDay.Hours * 60) + utcNow.TimeOfDay.Minutes

        ' If now is not within the range of available times . . .
        If Not((pq.StartTimeOfDay < utcNowAsMinutesAfterMidnight) AndAlso (utcNowAsMinutesAfterMidnight < pq.UntilTimeOfDay)) Then
            statusReport = statusReport & " Is not available at this time of day. "
        End If
    End If
End Sub

注解

如果不是 UTC 时区,则必须添加或减去 60 的倍数才能设置或获取时区的正确时间。 例如,如果位于北美太平洋时区且夏令时无效,则本地时间比 UTC 早 8 小时。 若要在 StartTimeOfDay 时区设置为上午 12 点,请将它设置为 8 AM UTC,即 480 (= 8 * 60) 。 你还必须记住,时间在 24 小时后滚动到零, (即:第1439分钟后) 。 若要将其设置为时区的下午 6 点,请将它设置为 2 AM UTC,即 120 (= 2 * 60) 。 有关有用的时区操作方法,请参阅TimeZoneTimeSpanDateTime类。

如果打印机始终可用,则此属性在所有时区中返回 0。

适用于

另请参阅